Documentation
¶
Index ¶
- func Debug(msg string, kvs ...any)
- func Error(msg string, kvs ...any)
- func Fatal(msg string, kvs ...any)
- func Info(msg string, kvs ...any)
- func Init(opts *Options)
- func New(opts *Options) *zapLogger
- func Panic(msg string, kvs ...any)
- func Sync()
- func Warn(msg string, kvs ...any)
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface {
Debug(msg string, kvs ...any)
Info(msg string, kvs ...any)
Warn(msg string, kvs ...any)
Error(msg string, kvs ...any)
// Fatal logs a message at the Fatal level and exits the application.
Fatal(msg string, kvs ...any)
// Panic logs a message at the Panic level and panics.
Panic(msg string, kvs ...any)
// Sync flushes any buffered log entries.
Sync()
}
Logger is an interface that defines the methods for logging.
type Options ¶
type Options struct {
// DisableCaller specifies whether to disable the caller information.
// If set to false (the default value), the file name and line number where the call log is located will be displayed in the log,
// for example :" caller":"main.go:42".
DisableCaller bool
// DisableStacktrace specifies whether to disable the stack trace information.
// If set to false (the default value), the stack trace information will be displayed in the log when the log level is panic or fatal.
// For example, if the log level is panic, the stack trace information will be displayed in the log.
DisableStacktrace bool
// Level specifies the log level.
// The default value is "info".
// The log level can be set to "debug", "info", "warn", "error", "panic", or "fatal".
Level string
// Format specifies the log format.
// The default value is "console".
// The log format can be set to "json" or "console".
Format string
// OutputPaths specifies the output path of the log.
// The default value is "stdout".
// The output path can be set to "stdout", "stderr", or a file path.
// For example, "stdout" will output the log to the standard output,
// "stderr" will output the log to the standard error, and "/var/log/app.log" will output the log to the file "/var/log/app.log".
// The output path can also be set to multiple paths, for example, "stdout,stderr,/var/log/app.log".
// In this case, the log will be output to the standard output, standard error, and the file "/var/log/app.log".
OutputPaths []string
}
Options defines the options for the logger.
func NewOptions ¶
func NewOptions() *Options
Click to show internal directories.
Click to hide internal directories.