Documentation
¶
Index ¶
- Constants
- Variables
- func AppendLogExtras(ctx context.Context, extra map[string]string) context.Context
- func AppendLogKv(ctx context.Context, key, value string) context.Context
- func CtxDebug(ctx context.Context, format string, v ...interface{})
- func CtxError(ctx context.Context, format string, v ...interface{})
- func CtxFatal(ctx context.Context, format string, v ...interface{})
- func CtxInfo(ctx context.Context, format string, v ...interface{})
- func CtxNotice(ctx context.Context, format string, v ...interface{})
- func CtxTrace(ctx context.Context, format string, v ...interface{})
- func CtxWarn(ctx context.Context, format string, v ...interface{})
- func Debug(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Fatal(format string, v ...interface{})
- func GetAllCustomFields(ctx context.Context) map[string]string
- func GetGID() string
- func GetPID() string
- func Info(format string, v ...interface{})
- func Notice(format string, v ...interface{})
- func SetLevel(level Level)
- func SetLogFile(fileName string, ops ...LogfileOption)
- func SetLogger(fullLogger klog.FullLogger)
- func SetLoggerType(t LoggerType)
- func SetOutput(w io.Writer)
- func SetProdEnv()
- func Trace(format string, v ...interface{})
- func Warn(format string, v ...interface{})
- func WithHertz()
- func WithKitex()
- type Formatter
- type HLogger
- type Level
- type LogfileOption
- type Logger
- type LoggerType
Constants ¶
const CustomFieldsKey = "ctx_extra_data"
const TraceIDKey = "trace_id"
Variables ¶
var LevelStr = [7]string{}
Functions ¶
func AppendLogExtras ¶
AppendLogExtras 注意,此函数并非并发安全,请勿在初始化之外等常见进行写入
func AppendLogKv ¶
AppendLogKv 注意,此函数并非并发安全,请勿在初始化之外等常见进行写入
func Debug ¶
func Debug(format string, v ...interface{})
Debug calls the default logger's Debugf method.
func Error ¶
func Error(format string, v ...interface{})
Error calls the default logger's Errorf method.
func Fatal ¶
func Fatal(format string, v ...interface{})
Fatal calls the default logger's Fatalf method and then os.Exit(1).
func Info ¶
func Info(format string, v ...interface{})
Info calls the default logger's Infof method.
func Notice ¶
func Notice(format string, v ...interface{})
Notice calls the default logger's Noticef method.
func SetLevel ¶
func SetLevel(level Level)
SetLevel sets the level of logs below which logs will not be output. The default log level is LevelTrace. Note that this method is not concurrent-safe.
func SetLogFile ¶
func SetLogFile(fileName string, ops ...LogfileOption)
SetLogFile sets log output to file and stdout. Use lumberjack to rolling file.
func SetLogger ¶
func SetLogger(fullLogger klog.FullLogger)
func SetLoggerType ¶
func SetLoggerType(t LoggerType)
SetLoggerType sets the logger type (must be called before logger initialization) Note: This should be called before any logging operations
func SetProdEnv ¶
func SetProdEnv()
func Trace ¶
func Trace(format string, v ...interface{})
Trace calls the default logger's Tracef method.
Types ¶
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.
The levels of logs.
func GetLogLevel ¶
func GetLogLevel() Level
type LogfileOption ¶
type LogfileOption interface {
// contains filtered or unexported methods
}
LogfileOption is the only way to config log file option.
func WithMaxAge ¶
func WithMaxAge(age int) LogfileOption
WithMaxAge set maximum days to keep expired files
func WithMaxBackups ¶
func WithMaxBackups(backups int) LogfileOption
WithMaxBackups set maximum number of expired files to keep
type Logger ¶
type Logger struct {
klog.FullLogger
// contains filtered or unexported fields
}
Logger wraps different logger implementations
type LoggerType ¶
type LoggerType string
LoggerType defines the type of logger to use
const ( LoggerTypeLogrus LoggerType = "logrus" LoggerTypeZerolog LoggerType = "zerolog" )