Documentation ¶
Index ¶
- func Debug(msg string)
- func DebugF(msg string, a ...any)
- func Error(msg string)
- func ErrorF(msg string, a ...any)
- func Fatal(msg string)
- func FatalF(msg string, a ...any)
- func Info(msg string)
- func InfoF(msg string, a ...any)
- func Panic(msg string)
- func PanicF(msg string, a ...any)
- func Print(a ...any)
- func Printf(format string, a ...any)
- func RegisterDefaultLogger(logger Logger)
- func SetFormat(format Format)
- func SetLevel(lvl Level)
- func Trace(msg string)
- func TraceF(msg string, a ...any)
- func Warn(msg string)
- func WarnF(msg string, a ...any)
- type Field
- type Format
- type Level
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDefaultLogger ¶
func RegisterDefaultLogger(logger Logger)
Types ¶
type Level ¶
type Level int8
const ( // DebugLevel defines debug log level. DebugLevel Level = iota // debug // InfoLevel defines info log level. InfoLevel // info // WarnLevel defines warn log level. WarnLevel // warn // ErrorLevel defines error log level. ErrorLevel // error // FatalLevel defines fatal log level. FatalLevel // fatal // PanicLevel defines panic log level. PanicLevel // panic // NoLevel defines an absent log level. NoLevel // no // Disabled disables the logger. Disabled // disabled // TraceLevel defines trace log level. TraceLevel Level = -1 // trace )
type Logger ¶
type Logger interface { io.Writer // With returns a new Logger with the specified field added to the context. With(name string, value any) Logger // Withs returns a new Logger with the specified fields added to the context. Withs(fields ...Field) Logger // WithLevel returns a new Logger with the specified level. WithLevel(lvl Level) Logger // WithFormat returns a new Logger with the specified format. WithFormat(format Format) Logger // Level returns the current level of the logger. Level() Level // Format returns the current format of the logger. Format() Format // SetLevel sets the current level of the logger. SetLevel(lvl Level) // SetFormat sets the format of the logger. SetFormat(format Format) // SetWriter sets the log output SetWriter(writer io.Writer) // Log logs a message at the specified level. Log(lvl Level, msg string) // LogF logs a formatted message at the specified level. LogF(lvl Level, msg string, a ...any) // Trace logs a trace message. Trace(msg string) // Debug logs a debug message. Debug(msg string) // Info logs an info message. Info(msg string) // Warn logs a warning message. Warn(msg string) // Error logs an error message. Error(msg string) // Fatal logs a fatal message and then panics. Fatal(msg string) // Panic logs a panic message and then panics. Panic(msg string) // TraceF logs a formatted trace message. TraceF(msg string, a ...any) // DebugF logs a formatted debug message. DebugF(msg string, a ...any) // InfoF logs a formatted info message. InfoF(msg string, a ...any) // WarnF logs a formatted warning message. WarnF(msg string, a ...any) // ErrorF logs a formatted error message. ErrorF(msg string, a ...any) // FatalF logs a formatted fatal message and then panics. FatalF(msg string, a ...any) // PanicF logs a formatted panic message and then panics. PanicF(msg string, a ...any) }
Logger is an interface that defines the logging functionality of a program.
func WithFormat ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.