diff options
| author | Felix Hanley <felix@userspace.com.au> | 2017-11-23 03:43:19 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2017-11-23 03:43:19 +0000 |
| commit | 3989a52562a41d6331a485900bc466917e2057bd (patch) | |
| tree | 028a19eba6a6bea3f2135d8597fc4b7f2530639a | |
| parent | f519e583e7f0db3dcf8fe3a34de9fdd56068030e (diff) | |
| download | logger-3989a52562a41d6331a485900bc466917e2057bd.tar.gz logger-3989a52562a41d6331a485900bc466917e2057bd.tar.bz2 | |
Update formatting options and logger setup
| -rw-r--r-- | kv_writer.go | 4 | ||||
| -rw-r--r-- | log.go | 6 | ||||
| -rw-r--r-- | options.go | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/kv_writer.go b/kv_writer.go index 7bf58dd..55ffbe1 100644 --- a/kv_writer.go +++ b/kv_writer.go @@ -8,6 +8,10 @@ import ( type KeyValueWriter struct{} +func NewKeyValueWriter() *KeyValueWriter { + return &KeyValueWriter{} +} + func (kv KeyValueWriter) Write(w *bufio.Writer, m Message) { w.WriteString(m.Time) w.WriteByte(' ') @@ -7,8 +7,6 @@ import ( "time" ) -const defaultTimeFormat = "2006-01-02T15:04:05.000Z0700" - type logger struct { name string level Level @@ -31,7 +29,7 @@ func New(opts *Options) Logger { timeFormat := opts.TimeFormat if timeFormat == "" { - timeFormat = defaultTimeFormat + timeFormat = DefaultTimeFormat } level := opts.Level @@ -49,7 +47,7 @@ func New(opts *Options) Logger { l.formatter = opts.Formatter if l.formatter == nil { - l.formatter = &KeyValueWriter{} + l.formatter = NewKeyValueWriter() } return &l @@ -2,6 +2,9 @@ package logger import "io" +// DefaultTimeFormat unless specified by options +const DefaultTimeFormat = "2006-01-02T15:04:05.000Z0700" + type Options struct { Name string Level Level |
