Documentation
¶
Index ¶
- func Debug(v ...any)
- func Debugf(format string, v ...any)
- func Debugw(msg string, keysAndValues ...any)
- func Error(v ...any)
- func Errorf(format string, v ...any)
- func Errorw(msg string, keysAndValues ...any)
- func Fatal(v ...any)
- func Fatalf(format string, v ...any)
- func Fatalw(msg string, keysAndValues ...any)
- func Info(v ...any)
- func Infof(format string, v ...any)
- func Infow(msg string, keysAndValues ...any)
- func Panic(v ...any)
- func Panicf(format string, v ...any)
- func Panicw(msg string, keysAndValues ...any)
- func SetLevel(lv Level)
- func SetLogger(v AllLogger)
- func SetOutput(w io.Writer)
- func Trace(v ...any)
- func Tracef(format string, v ...any)
- func Tracew(msg string, keysAndValues ...any)
- func Warn(v ...any)
- func Warnf(format string, v ...any)
- func Warnw(msg string, keysAndValues ...any)
- type AllLogger
- type CommonLogger
- type ControlLogger
- type FormatLogger
- type Level
- type Logger
- type WithLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debugw ¶
Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.
func Errorw ¶
Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.
func Fatal ¶
func Fatal(v ...any)
Fatal calls the default logger's Fatal method and then os.Exit(1).
func Fatalw ¶
Fatalw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.
func Infow ¶
Infow logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.
func Panicw ¶
Panicw logs a message with some additional context. The variadic key-value pairs are treated as they are privateLog With.
func SetLevel ¶
func SetLevel(lv Level)
SetLevel sets the level of logs below which logs will not be output. The default logger is LevelTrace. Note that this method is not concurrent-safe.
func SetLogger ¶
func SetLogger(v AllLogger)
SetLogger sets the default logger and the system logger. Note that this method is not concurrent-safe and must not be called after the use of DefaultLogger and global functions privateLog this package.
func SetOutput ¶
SetOutput sets the output of default logger and system logger. By default, it is stderr.
Types ¶
type AllLogger ¶
type AllLogger interface { CommonLogger ControlLogger WithContext(ctx context.Context) CommonLogger }
AllLogger is the combination of Logger, FormatLogger, CtxLogger and ControlLogger. Custom extensions can be made through AllLogger
type CommonLogger ¶
type CommonLogger interface { Logger FormatLogger WithLogger }
func WithContext ¶
func WithContext(ctx context.Context) CommonLogger
type ControlLogger ¶
ControlLogger provides methods to config a logger.
type FormatLogger ¶
type FormatLogger interface { Tracef(format string, v ...any) Debugf(format string, v ...any) Infof(format string, v ...any) Warnf(format string, v ...any) Errorf(format string, v ...any) Fatalf(format string, v ...any) Panicf(format string, v ...any) }
FormatLogger is a logger interface that output logs with a format.
type Level ¶
type Level int
Level defines the priority of a log message. When a logger is configured with a level, any log message with a lower log level (smaller by integer comparison) will not be output.
type Logger ¶
type Logger interface { Trace(v ...any) Debug(v ...any) Info(v ...any) Warn(v ...any) Error(v ...any) Fatal(v ...any) Panic(v ...any) }
Logger is a logger interface that provides logging function with levels.
type WithLogger ¶
type WithLogger interface { Tracew(msg string, keysAndValues ...any) Debugw(msg string, keysAndValues ...any) Infow(msg string, keysAndValues ...any) Warnw(msg string, keysAndValues ...any) Errorw(msg string, keysAndValues ...any) Fatalw(msg string, keysAndValues ...any) Panicw(msg string, keysAndValues ...any) }
WithLogger is a logger interface that output logs with a message and key-value pairs.