Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
Hook is the log hook type. Before the log is written, the corresponding level of hooks will be executed. The hooks will be executed sequentially in synchronization until an error is encountered or all execution is complete.
type Level ¶
type Level uint32
The log level type.
const ( // PanicLevel indicates a very serious event at the highest level. // When the log is written, panic will be triggered automatically. PanicLevel Level = iota + 1 // FatalLevel indicates that an event occurred that the application // cannot continue to run. When the log is written, the exit function // will be called automatically. FatalLevel // ErrorLevel indicates that an event occurred within the application // but does not affect continued operation. ErrorLevel // WarnLevel indicates that a noteworthy event has occurred inside // the application. WarnLevel // InfoLevel represents some general information events. InfoLevel // DebugLevel represents some informational events for debugging, and // very verbose logging. DebugLevel // TraceLevel represents the finest granular information event. TraceLevel )
func MustParseLevel ¶
Parses the log level from the given string. If the given string is invalid, it will panic.
func ParseLevel ¶
Parses the log level from the given string.
type Log ¶
type Log interface {
// Gets the name of the logger.
Name() string
// Add an extra data to the current log.
// This method will return a new log instance.
WithField(string, interface{}) Log
// Add error to the current log.
// This method will return a new log instance.
// This method is relative to WithField("error", error).
WithError(error) Log
// Add extra data to the current log.
// This method will return a new log instance.
WithFields(map[string]interface{}) Log
// Add context to the current log.
// This method will return a new log instance.
WithContext(context.Context) Log
// Record the current log and specify the level.
Log(Level, ...interface{})
Logln(Level, ...interface{})
Logf(Level, string, ...interface{})
// Record the current log and specify the level as TraceLevel.
Trace(...interface{})
Traceln(...interface{})
Tracef(string, ...interface{})
Print(...interface{})
Println(...interface{})
Printf(string, ...interface{})
// Record the current log and specify the level as DebugLevel.
Debug(...interface{})
Debugln(...interface{})
Debugf(string, ...interface{})
// Record the current log and specify the level as InfoLevel.
Info(...interface{})
Infoln(...interface{})
Infof(string, ...interface{})
// Record the current log and specify the level as WarnLevel.
Warn(...interface{})
Warnln(...interface{})
Warnf(string, ...interface{})
Warning(...interface{})
Warningln(...interface{})
Warningf(string, ...interface{})
// Record the current log and specify the level as ErrorLevel.
Error(...interface{})
Errorln(...interface{})
Errorf(string, ...interface{})
// Record the current log and specify the level as FatalLevel.
// The exit function will be executed automatically.
Fatal(...interface{})
Fatalln(...interface{})
Fatalf(string, ...interface{})
// Record the current log and specify the level as PanicLevel.
// Panic will be triggered automatically.
Panic(...interface{})
Panicln(...interface{})
Panicf(string, ...interface{})
}
type Logger ¶
type Logger interface {
Log
// Get the current logger level.
GetLevel() Level
// Set the current logger level.
SetLevel(Level) Logger
// Get the current logger output writer.
GetOutput() io.Writer
// Set the current logger output writer.
SetOutput(io.Writer) Logger
// Set the current logger system exit function.
WithExitFunc(func(int)) Logger
// Register hook to the current logger.
WithHook([]Level, Hook) Logger
}
Definition of the logger.
type Summary ¶
type Summary interface {
Name() string // Get the name of the logger.
Bytes() []byte // Get the log content and return it as bytes.
String() string // Get the log content and return it as string.
Size() int // Get the size of the log.
Level() Level // Get the level of the log.
Time() time.Time // Get the creation time of the log.
Message() string // Get the message of the log.
Fields() map[string]interface{} // Get the bound data of the log.
Field(string) (interface{}, bool) // Query the bound data of the log.
Context() context.Context // Get the context of the log.
}
Summary of the log.
Click to show internal directories.
Click to hide internal directories.