2
0

refactor internally a little to clean up the code. Make the main example a real example so we make sure it compiles

This commit is contained in:
Nate Finch
2014-06-16 12:55:21 -04:00
parent 03e9c77b42
commit fc6790d66f
3 changed files with 75 additions and 71 deletions
+16 -12
View File
@@ -11,22 +11,26 @@ to which logs are written.
Lumberjack plays well with any logger that can write to an io.Writer,
including the standard library's log package.
For example, to use lumberjack with the std lib's log package, just pass it
into the SetOutput function when your application starts:
log.SetOutput(&lumberjack.Logger{
Dir: "/var/log/myapp/"
NameFormat: time.RFC822+".log",
MaxSize: lumberjack.Gigabyte,
MaxBackups: 3,
MaxAge: lumberjack.Week * 4,
))
Lumberjack assumes that only one process is writing to the output files.
Using the same lumberjack configuration from multiple processes on the same
machine will result in improper behavior.
#### Example
To use lumberjack with the standard library's log package, just pass it into the
SetOutput function when your application starts.
Code:
```go
log.SetOutput(&lumberjack.Logger{
Dir: "/var/log/myapp/",
NameFormat: time.RFC822 + ".log",
MaxSize: lumberjack.Gigabyte,
MaxBackups: 3,
MaxAge: lumberjack.Week * 4,
})
```