rename module
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# lumberjack [](https://godoc.org/gopkg.in/natefinch/lumberjack.v2) [](https://travis-ci.org/natefinch/lumberjack) [](https://ci.appveyor.com/project/natefinch/lumberjack) [](https://coveralls.io/r/natefinch/lumberjack?branch=v2.0)
|
# lumberjack [](https://godoc.org/gopkg.in/natefinch/lumberjack.v2) [](https://travis-ci.org/natefinch/lumberjack) [](https://ci.appveyor.com/project/natefinch/lumberjack) [](https://coveralls.io/r/natefinch/lumberjack?branch=v2.0)
|
||||||
|
|
||||||
### Lumberjack is a Go package for writing logs to rolling files.
|
### Lumberjack is a Go package for writing logs to rolling files.
|
||||||
|
|
||||||
@@ -7,10 +7,10 @@ Package lumberjack provides a rolling logger.
|
|||||||
Note that this is v2.0 of lumberjack, and should be imported using gopkg.in
|
Note that this is v2.0 of lumberjack, and should be imported using gopkg.in
|
||||||
thusly:
|
thusly:
|
||||||
|
|
||||||
import "gopkg.in/natefinch/lumberjack.v2"
|
import "git.corp.kornet35.ru/gopkg/lumberjack/v2"
|
||||||
|
|
||||||
The package name remains simply lumberjack, and the code resides at
|
The package name remains simply lumberjack, and the code resides at
|
||||||
https://github.com/natefinch/lumberjack under the v2.0 branch.
|
https://git.corp.kornet35.ru/gopkg/lumberjack under the v2.0 branch.
|
||||||
|
|
||||||
Lumberjack is intended to be one part of a logging infrastructure.
|
Lumberjack is intended to be one part of a logging infrastructure.
|
||||||
It is not an all-in-one solution, but instead is a pluggable
|
It is not an all-in-one solution, but instead is a pluggable
|
||||||
@@ -24,7 +24,6 @@ Lumberjack assumes that only one process is writing to the output files.
|
|||||||
Using the same lumberjack configuration from multiple processes on the same
|
Using the same lumberjack configuration from multiple processes on the same
|
||||||
machine will result in improper behavior.
|
machine will result in improper behavior.
|
||||||
|
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
To use lumberjack with the standard library's log package, just pass it into the SetOutput function when your application starts.
|
To use lumberjack with the standard library's log package, just pass it into the SetOutput function when your application starts.
|
||||||
@@ -41,10 +40,9 @@ log.SetOutput(&lumberjack.Logger{
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## type Logger
|
## type Logger
|
||||||
``` go
|
|
||||||
|
```go
|
||||||
type Logger struct {
|
type Logger struct {
|
||||||
// Filename is the file to write logs to. Backup log files will be retained
|
// Filename is the file to write logs to. Backup log files will be retained
|
||||||
// in the same directory. It uses <processname>-lumberjack.log in
|
// in the same directory. It uses <processname>-lumberjack.log in
|
||||||
@@ -78,9 +76,10 @@ type Logger struct {
|
|||||||
// contains filtered or unexported fields
|
// contains filtered or unexported fields
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Logger is an io.WriteCloser that writes to the specified filename.
|
Logger is an io.WriteCloser that writes to the specified filename.
|
||||||
|
|
||||||
Logger opens or creates the logfile on first Write. If the file exists and
|
Logger opens or creates the logfile on first Write. If the file exists and
|
||||||
is less than MaxSize megabytes, lumberjack will open and append to that file.
|
is less than MaxSize megabytes, lumberjack will open and append to that file.
|
||||||
If the file exists and its size is >= MaxSize megabytes, the file is renamed
|
If the file exists and its size is >= MaxSize megabytes, the file is renamed
|
||||||
by putting the current time in a timestamp in the name immediately before the
|
by putting the current time in a timestamp in the name immediately before the
|
||||||
@@ -95,47 +94,40 @@ file.
|
|||||||
Backups use the log file name given to Logger, in the form `name-timestamp.ext`
|
Backups use the log file name given to Logger, in the form `name-timestamp.ext`
|
||||||
where name is the filename without the extension, timestamp is the time at which
|
where name is the filename without the extension, timestamp is the time at which
|
||||||
the log was rotated formatted with the time.Time format of
|
the log was rotated formatted with the time.Time format of
|
||||||
`2006-01-02T15-04-05.000` and the extension is the original extension. For
|
`2006-01-02T15-04-05.000` and the extension is the original extension. For
|
||||||
example, if your Logger.Filename is `/var/log/foo/server.log`, a backup created
|
example, if your Logger.Filename is `/var/log/foo/server.log`, a backup created
|
||||||
at 6:30pm on Nov 11 2016 would use the filename
|
at 6:30pm on Nov 11 2016 would use the filename
|
||||||
`/var/log/foo/server-2016-11-04T18-30-00.000.log`
|
`/var/log/foo/server-2016-11-04T18-30-00.000.log`
|
||||||
|
|
||||||
### Cleaning Up Old Log Files
|
### Cleaning Up Old Log Files
|
||||||
Whenever a new logfile gets created, old log files may be deleted. The most
|
|
||||||
|
Whenever a new logfile gets created, old log files may be deleted. The most
|
||||||
recent files according to the encoded timestamp will be retained, up to a
|
recent files according to the encoded timestamp will be retained, up to a
|
||||||
number equal to MaxBackups (or all of them if MaxBackups is 0). Any files
|
number equal to MaxBackups (or all of them if MaxBackups is 0). Any files
|
||||||
with an encoded timestamp older than MaxAge days are deleted, regardless of
|
with an encoded timestamp older than MaxAge days are deleted, regardless of
|
||||||
MaxBackups. Note that the time encoded in the timestamp is the rotation
|
MaxBackups. Note that the time encoded in the timestamp is the rotation
|
||||||
time, which may differ from the last time that file was written to.
|
time, which may differ from the last time that file was written to.
|
||||||
|
|
||||||
If MaxBackups and MaxAge are both 0, no old log files will be deleted.
|
If MaxBackups and MaxAge are both 0, no old log files will be deleted.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Logger) Close
|
### func (\*Logger) Close
|
||||||
``` go
|
|
||||||
|
```go
|
||||||
func (l *Logger) Close() error
|
func (l *Logger) Close() error
|
||||||
```
|
```
|
||||||
|
|
||||||
Close implements io.Closer, and closes the current logfile.
|
Close implements io.Closer, and closes the current logfile.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Logger) Rotate
|
### func (\*Logger) Rotate
|
||||||
``` go
|
|
||||||
|
```go
|
||||||
func (l *Logger) Rotate() error
|
func (l *Logger) Rotate() error
|
||||||
```
|
```
|
||||||
|
|
||||||
Rotate causes Logger to close the existing log file and immediately create a
|
Rotate causes Logger to close the existing log file and immediately create a
|
||||||
new one. This is a helper function for applications that want to initiate
|
new one. This is a helper function for applications that want to initiate
|
||||||
rotations outside of the normal rotation rules, such as in response to
|
rotations outside of the normal rotation rules, such as in response to
|
||||||
SIGHUP. After rotating, this initiates a cleanup of old log files according
|
SIGHUP. After rotating, this initiates a cleanup of old log files according
|
||||||
to the normal rules.
|
to the normal rules.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
@@ -159,21 +151,16 @@ go func() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### func (\*Logger) Write
|
### func (\*Logger) Write
|
||||||
``` go
|
|
||||||
|
```go
|
||||||
func (l *Logger) Write(p []byte) (n int, err error)
|
func (l *Logger) Write(p []byte) (n int, err error)
|
||||||
```
|
```
|
||||||
Write implements io.Writer. If a write would cause the log file to be larger
|
|
||||||
|
Write implements io.Writer. If a write would cause the log file to be larger
|
||||||
than MaxSize, the file is closed, renamed to include a timestamp of the
|
than MaxSize, the file is closed, renamed to include a timestamp of the
|
||||||
current time, and a new log file is created using the original log file name.
|
current time, and a new log file is created using the original log file name.
|
||||||
If the length of the write is greater than MaxSize, an error is returned.
|
If the length of the write is greater than MaxSize, an error is returned.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- - -
|
|
||||||
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)
|
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module gopkg.in/natefinch/lumberjack.v2
|
module git.corp.kornet35.ru/gopkg/lumberjack/v2
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|||||||
+3
-3
@@ -3,10 +3,10 @@
|
|||||||
// Note that this is v2.0 of lumberjack, and should be imported using gopkg.in
|
// Note that this is v2.0 of lumberjack, and should be imported using gopkg.in
|
||||||
// thusly:
|
// thusly:
|
||||||
//
|
//
|
||||||
// import "gopkg.in/natefinch/lumberjack.v2"
|
// import "git.corp.kornet35.ru/gopkg/lumberjack/v2"
|
||||||
//
|
//
|
||||||
// The package name remains simply lumberjack, and the code resides at
|
// The package name remains simply lumberjack, and the code resides at
|
||||||
// https://github.com/natefinch/lumberjack under the v2.0 branch.
|
// https://git.corp.kornet35.ru/gopkg/lumberjack under the v2.0 branch.
|
||||||
//
|
//
|
||||||
// Lumberjack is intended to be one part of a logging infrastructure.
|
// Lumberjack is intended to be one part of a logging infrastructure.
|
||||||
// It is not an all-in-one solution, but instead is a pluggable
|
// It is not an all-in-one solution, but instead is a pluggable
|
||||||
@@ -66,7 +66,7 @@ var _ io.WriteCloser = (*Logger)(nil)
|
|||||||
// `/var/log/foo/server.log`, a backup created at 6:30pm on Nov 11 2016 would
|
// `/var/log/foo/server.log`, a backup created at 6:30pm on Nov 11 2016 would
|
||||||
// use the filename `/var/log/foo/server-2016-11-04T18-30-00.000.log`
|
// use the filename `/var/log/foo/server-2016-11-04T18-30-00.000.log`
|
||||||
//
|
//
|
||||||
// Cleaning Up Old Log Files
|
// # Cleaning Up Old Log Files
|
||||||
//
|
//
|
||||||
// Whenever a new logfile gets created, old log files may be deleted. The most
|
// Whenever a new logfile gets created, old log files may be deleted. The most
|
||||||
// recent files according to the encoded timestamp will be retained, up to a
|
// recent files according to the encoded timestamp will be retained, up to a
|
||||||
|
|||||||
Reference in New Issue
Block a user