Skip to content

Commit 8e6efea

Browse files
committed
More README
1 parent 0c93de2 commit 8e6efea

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Minimalistic logging library.
1818

1919
The constructor accepts several options:
2020

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
2525

2626
## Defaults
2727

@@ -31,15 +31,21 @@ If no options are given, the following are assumed.
3131
WithOutput(os.Stdout)
3232
WithTimeFormat(DefaultTimeFormat, true)
3333

34+
The default time format is `2006-01-02 15:04:05.000`.
35+
3436
# Usage
3537

3638
```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
4551
```

0 commit comments

Comments
 (0)