aboutsummaryrefslogtreecommitdiff
path: root/logger.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2019-05-03 03:07:15 +0000
committerFelix Hanley <felix@userspace.com.au>2019-05-03 03:07:15 +0000
commitfee69f239c0207ba7a5911a892055de3da81d17b (patch)
treeb24a7f77cac035b2dc2359718a4c7d9a4c38097b /logger.go
parentc122087dfa1ecdb5a46dc8a6dcf1960622073885 (diff)
downloadlogger-fee69f239c0207ba7a5911a892055de3da81d17b.tar.gz
logger-fee69f239c0207ba7a5911a892055de3da81d17b.tar.bz2
Better field storage
Diffstat (limited to 'logger.go')
-rw-r--r--logger.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/logger.go b/logger.go
index 04e5f50..243c1ec 100644
--- a/logger.go
+++ b/logger.go
@@ -13,7 +13,7 @@ import (
type Logger struct {
name string
min message.Level
- fields []interface{}
+ fields map[string]interface{}
timeFormat string
writers []message.Writer
lock sync.Mutex
@@ -23,6 +23,7 @@ type Logger struct {
func New(opts ...Option) (*Logger, error) {
l := &Logger{
min: message.ERROR,
+ fields: make(map[string]interface{}),
timeFormat: "2006-01-02T15:04:05.000Z0700",
}
@@ -109,7 +110,7 @@ func (l *Logger) SetLevel(lvl message.Level) { l.min = lvl }
// SetField enables changing the default fields for a logger instance.
func (l *Logger) SetField(k string, v interface{}) {
- l.fields = append(l.fields, k, v)
+ l.fields[k] = v
}
// SetName enables changing the name for a logger instance.