Documentation ¶
Overview ¶
Output log to files. By default it writes to xxx.log file and saves xxx.log to xxx.log.<date> and opens an new xxx.log file when an new day begins. And it will also remove log files 7 days ago. Log file name, output dir and log file lifetime can be customized.
Extended logging pkg for go. Output log format:
"LEVEL: DATE TIME: g=GOROUTINE_ID: FILE:LINE: LOG_CONTENT\n"
eg:
"NOTICE: 08-06 10:45:19.598: g=12: bvc.go:100: hello world"
Index ¶
- Variables
- func DailyChecker(now *time.Time, logfile *string) bool
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Notice(v ...interface{})
- func Noticef(format string, v ...interface{})
- func SetLevel(level Level)
- func SetOutput(w io.Writer)
- func SetUpFileLogger(logdir, prefix string, checker LogChecker) error
- func Trace(v ...interface{})
- func Tracef(format string, v ...interface{})
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- type FileLogger
- type Level
- type LogChecker
- type Logger
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DailyChecker ¶
DailyChecker returns true if now is the succeed day of daily.today
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf is equivalent to Printf() for DEBUG-level log.
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf is equivalent to Printf() for FATAL-level log.
func Noticef ¶
func Noticef(format string, v ...interface{})
Noticef is equivalent to Printf() for NOTICE-level log.
func SetUpFileLogger ¶
func SetUpFileLogger(logdir, prefix string, checker LogChecker) error
Types ¶
type FileLogger ¶
type FileLogger struct {
// contains filtered or unexported fields
}
type LogChecker ¶
LogChecker function returns true if need to close current log file and open an new one. now variable contains current time, and logfile contains absolute path of current log file.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger represents an active logging object that generates lines of output to an io.Writer. Each logging operation makes a single call to the Writer's Write method. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.
func New ¶
New creates a new Logger. The level variable sets the logger level. And the out variable sets the destination to which log data will be written.
func (*Logger) Output ¶
Output writes the output for a logging event. The level variable indicates the output message level. Note, only message level greater than or equals to logger level can be written. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 2. The string s contains the text to print. A newline is appended if the last character of s is not already a newline.