@@ -18,10 +18,10 @@ Minimalistic logging library.
18
18
19
19
The constructor accepts several options:
20
20
21
- func WithLevel(level Level) Option
22
- func WithOutput(output io.Writer) Option
23
- func WithPrefix(prefix string) Option
24
- func WithTimeFormat(format string, utc bool) Option
21
+ WithLevel(level Level) // Set level
22
+ WithOutput(output io.Writer) // Set output
23
+ WithPrefix(prefix string) // Set prefix
24
+ WithTimeFormat(format string, utc bool) // Set time format and UTC flag
25
25
26
26
## Defaults
27
27
@@ -31,15 +31,21 @@ If no options are given, the following are assumed.
31
31
WithOutput(os.Stdout)
32
32
WithTimeFormat(DefaultTimeFormat, true)
33
33
34
+ The default time format is ` 2006-01-02 15:04:05.000 ` .
35
+
34
36
# Usage
35
37
36
38
``` go
37
- l := picolo.New (WithPrefix (" [some-prefix]" )) // constructor with optional prefix
38
- l.Debugf (" Debug message" )
39
- // TIME LEVEL [some-prefix] Debug message
40
-
41
- // Create sub-logger, appending prefix
42
- k := picolo.NewFrom (l, " [more-prefix]" )
43
- k.Debugf (" Debug message" )
44
- // TIME LEVEL [some-prefix] [more-prefix] Debug message
39
+ l := picolo.New () // Use defaults
40
+ l.Infof (" Info message" )
41
+ // 2017-12-21 22:23:24.256 INFO Info message
42
+
43
+ l = picolo.New (picolo.WithPrefix (" [some-prefix]" )) // constructor with optional prefix
44
+ l.Infof (" Info message" )
45
+ // 2017-12-21 22:23:24.256 INFO [some-prefix] Info message
46
+
47
+ // Create sub-logger, appending prefix
48
+ k := picolo.NewFrom (l, " [more-prefix]" )
49
+ k.Errorf (" Error message: %v " , err)
50
+ // 2017-12-21 23:24:25.267 ERROR [some-prefix] [more-prefix] Error message: No such file or directory
45
51
```
0 commit comments