Documentation ¶
Index ¶
- Constants
- func Close()
- func Debug(args ...interface{})
- func Error(args ...interface{})
- func Fatal(args ...interface{})
- func Info(args ...interface{})
- func Panic(args ...interface{})
- func Regist(logger Logger)
- func SetFormatter(logger string, formatter Formatter) error
- func SetMode(mode string)
- func Trace(args ...interface{})
- func Verbose(args ...interface{})
- func Warning(args ...interface{})
- type Fields
- func (f Fields) Debug(args ...interface{})
- func (f Fields) Error(args ...interface{})
- func (f Fields) Fatal(args ...interface{})
- func (f Fields) Info(args ...interface{})
- func (f Fields) Panic(args ...interface{})
- func (f Fields) Trace(args ...interface{})
- func (f Fields) Verbose(args ...interface{})
- func (f Fields) Warning(args ...interface{})
- type Formatter
- type JSONFormatter
- type Level
- type Logger
- type Message
- type Option
- func Colorful() Option
- func Path(path string, patterns ...string) Option
- func RotateDuration(duration time.Duration) Option
- func RotateFileSize(size int64) Option
- func RotatePolicy(policy string) Option
- func SweepFileCount(count int) Option
- func SweepInterval(interval time.Duration) Option
- func SweepPolicy(policy string) Option
- type TextFormatter
Constants ¶
View Source
const ( RotateByDuration = "RotateByDuration" RotateBySize = "RotateBySize" SweepByFileCount = "SweepByFileCount" SweepByInterval = "SweepByInterval" DefaultRotatePolicy = RotateByDuration DefaultSweepPolicy = SweepByFileCount DefaultRotateFileSize = 50 << 20 // rotate log file every 50M DefaultRotateDuration = 24 * time.Hour // rotate log file every 24 hours DefaultSweepInterval = 7 * 24 * time.Hour // sweep log file 7 days before DefaultSweepFileCount = 5 )
View Source
const ( ModeRelease = "release" ModeDebug = "debug" )
View Source
const ( Console = "console" File = "file" Syslog = "syslog" )
View Source
const (
BufferCapacity = 8
)
Capacity of buffer channel
Variables ¶
This section is empty.
Functions ¶
func Fatal ¶
func Fatal(args ...interface{})
Fatal print fatal error message, and app will quit if this function called
func Panic ¶
func Panic(args ...interface{})
Panic print panic message, and app will trigger panic message if called
func Regist ¶
func Regist(logger Logger)
Regist adds a logger, Log package default add one logger(console), means default all the log message will print to console. But you can use this function to add new logger to log engine.
func SetFormatter ¶
Types ¶
type JSONFormatter ¶
type JSONFormatter struct{}
func (*JSONFormatter) Format ¶
func (jf *JSONFormatter) Format(msg *Message) string
type Level ¶
type Level uint8
const ( LevelPanic Level = iota LevelFatal LevelError LevelWarn LevelInfo LevelVerbose LevelDebug LevelTrace )
Log level
func (Level) MarshalJSON ¶
type Logger ¶
type Logger interface { // Name returns logger's name Name() string // Level returns logger's level Level() Level // Write writes a message to logger Write(msg *Message) // Close closes a logger Close() error }
Logger interface, all supported logger MUST implement this interface
func NewConsoleLogger ¶
NewConsoleLogger creates a new console logger
func NewFileLogger ¶
NewFileLogger creates a file logger implementation
type Message ¶
type Message struct { Level Level `json:"level"` Filename string `json:"filename,omitempty"` Function string `json:"function,omitempty"` Line int `json:"line,omitempty"` Message string `json:"message"` Timestamp time.Time `json:"timestamp"` Fields Fields `json:"-"` }
Message represents Log message record, minimal log dispatch unit
type Option ¶
type Option func(Logger)
func RotateDuration ¶
func RotateFileSize ¶
func RotatePolicy ¶
func SweepFileCount ¶
func SweepInterval ¶
func SweepPolicy ¶
type TextFormatter ¶
type TextFormatter struct {
// contains filtered or unexported fields
}
func (*TextFormatter) Format ¶
func (tf *TextFormatter) Format(msg *Message) (message string)
Click to show internal directories.
Click to hide internal directories.