Skip to content

Commit

Permalink
Merge pull request #28 from reidrac/update-readme-2.0
Browse files Browse the repository at this point in the history
Updated README to match 2.0 release
  • Loading branch information
rifflock committed Dec 12, 2017
2 parents 765177c + e455b2a commit 1e68690
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -17,18 +17,19 @@ func NewLogger( config map[string]interface{} ) *log.Logger {
}

Log = log.New()
Log.SetFormatter(&log.JSONFormatter{})
Log.Hooks.Add(lfshook.NewHook(lfshook.PathMap{
log.InfoLevel : "/var/log/info.log",
log.ErrorLevel : "/var/log/error.log",
}))
}, &log.JSONFormatter{}))
return Log
}
```

### Formatters
lfshook will strip colors from any TextFormatter type formatters when writing to local file, because the color codes don't look so great.

If no formatter is provided via `lfshook.NewHook`, a default text formatter will be used.

### Log rotation
In order to enable automatic log rotation it's possible to provide an io.Writer instead of the path string of a log file.
In combination with pakages like [go-file-rotatelogs](https://github.com/lestrrat/go-file-rotatelogs) log rotation can easily be achieved.
Expand All @@ -47,7 +48,7 @@ In combination with pakages like [go-file-rotatelogs](https://github.com/lestrra
log.Hooks.Add(lfshook.NewHook(lfshook.WriterMap{
logrus.InfoLevel: writer,
logrus.ErrorLevel: writer,
}))
}, nil))
```

### Note:
Expand Down

0 comments on commit 1e68690

Please sign in to comment.