@@ -103,19 +103,23 @@ If you with to know all the loggers of a kind, you can use:
103
103
By default, the preamble of the log will be a timestamp with a human readable format like this:
104
104
105
105
```
106
- 29 November 2018 00:06:30 : Test
106
+ 2018-11-29T23:19:55.511775+01:00 : Test
107
107
```
108
108
109
109
But this format is configurable. The ` timestampFormatBlock: ` method can be use with a parameter that is a block taking a stream as parameter and the timestamp (instance of DateAndTime) and use that to write the preamble on the stream.
110
110
111
111
``` Smalltalk
112
- TinyLogger default timestampFormatBlock: [ :s :timestamp | s << timestamp asString ]
112
+ TinyLogger default
113
+ timestampFormatBlock: [ :aStream :timestamp |
114
+ timestamp asDate printOn: aStream.
115
+ aStream << ' '. "Cannot use #space because of Stdio streams"
116
+ timestamp asTime print24: true on: aStream ]
113
117
```
114
118
115
119
This will produce logs of this format:
116
120
117
121
```
118
- 2018-11-29T00:46:37.389775+01:00 : Test
122
+ 29 November 2018 00:06:30 : Test
119
123
```
120
124
121
125
## Record with your logger
@@ -133,7 +137,7 @@ To record a single line log you can just use the method `record`:
133
137
This will produce a log like this with the default ` timestampFormatBlock ` :
134
138
135
139
```
136
- 29 November 2018 00:49:20 : This is a string to log
140
+ 2018-11-29T23:19:55.511775+01:00 : This is a string to log
137
141
```
138
142
139
143
### Recording the execution of a task
@@ -147,13 +151,13 @@ self execute: [ 1 to: 5 do: [ :value | value asString record ] ] recordedAs: 'Ta
147
151
Will produce a log like this:
148
152
149
153
```
150
- 29 November 2018 00:56:20 : Begin: Task with only one nesting.
151
- 29 November 2018 00:56:20 : 1
152
- 29 November 2018 00:56:20 : 2
153
- 29 November 2018 00:56:20 : 3
154
- 29 November 2018 00:56:20 : 4
155
- 29 November 2018 00:56:20 : 5
156
- 29 November 2018 00:56:20 : End: Task with only one nesting.
154
+ 2018-11-29T23:21:04.897775+01:00 : Begin: Task with only one nesting.
155
+ 2018-11-29T23:21:04.900775+01:00 : 1
156
+ 2018-11-29T23:21:04.902775+01:00 : 2
157
+ 2018-11-29T23:21:04.904775+01:00 : 3
158
+ 2018-11-29T23:21:04.906775+01:00 : 4
159
+ 2018-11-29T23:21:04.908775+01:00 : 5
160
+ 2018-11-29T23:21:04.909775+01:00 : End: Task with only one nesting.
157
161
```
158
162
159
163
It is also possible to nest them like that:
@@ -171,26 +175,26 @@ self execute: [
171
175
It will produce this kind of output:
172
176
173
177
```
174
- 29 November 2018 00:57:45 : Begin: My first nest
175
- 29 November 2018 00:57:45 : Begin: My second nest
176
- 29 November 2018 00:57:45 : 1
177
- 29 November 2018 00:57:45 : End: My second nest
178
- 29 November 2018 00:57:45 : Begin: My second nest
179
- 29 November 2018 00:57:45 : 1
180
- 29 November 2018 00:57:45 : 2
181
- 29 November 2018 00:57:45 : End: My second nest
182
- 29 November 2018 00:57:45 : Begin: My second nest
183
- 29 November 2018 00:57:45 : 1
184
- 29 November 2018 00:57:45 : 2
185
- 29 November 2018 00:57:45 : 3
186
- 29 November 2018 00:57:45 : End: My second nest
187
- 29 November 2018 00:57:45 : Begin: My second nest
188
- 29 November 2018 00:57:45 : 1
189
- 29 November 2018 00:57:45 : 2
190
- 29 November 2018 00:57:45 : 3
191
- 29 November 2018 00:57:45 : 4
192
- 29 November 2018 00:57:45 : End: My second nest
193
- 29 November 2018 00:57:45 : End: My first nest
178
+ 2018-11-29T23:21:20.147775+01:00 : Begin: My first nest
179
+ 2018-11-29T23:21:20.151775+01:00 : Begin: My second nest
180
+ 2018-11-29T23:21:20.153775+01:00 : 1
181
+ 2018-11-29T23:21:20.155775+01:00 : End: My second nest
182
+ 2018-11-29T23:21:20.157775+01:00 : Begin: My second nest
183
+ 2018-11-29T23:21:20.158775+01:00 : 1
184
+ 2018-11-29T23:21:20.160775+01:00 : 2
185
+ 2018-11-29T23:21:20.161775+01:00 : End: My second nest
186
+ 2018-11-29T23:21:20.163775+01:00 : Begin: My second nest
187
+ 2018-11-29T23:21:20.164775+01:00 : 1
188
+ 2018-11-29T23:21:20.165775+01:00 : 2
189
+ 2018-11-29T23:21:20.167775+01:00 : 3
190
+ 2018-11-29T23:21:20.169775+01:00 : End: My second nest
191
+ 2018-11-29T23:21:20.171775+01:00 : Begin: My second nest
192
+ 2018-11-29T23:21:20.172775+01:00 : 1
193
+ 2018-11-29T23:21:20.175775+01:00 : 2
194
+ 2018-11-29T23:21:20.176775+01:00 : 3
195
+ 2018-11-29T23:21:20.177775+01:00 : 4
196
+ 2018-11-29T23:21:20.179775+01:00 : End: My second nest
197
+ 2018-11-29T23:21:20.180775+01:00 : End: My first nest
194
198
```
195
199
196
200
## Use another logger than the global logger
0 commit comments