Documentation
¶
Index ¶
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(_ context.Context, msg string, keyvals ...any)
- func (l *Logger) Enabled(_ bLogger.Level) bool
- func (l *Logger) Error(_ context.Context, msg string, keyvals ...any)
- func (l *Logger) Info(_ context.Context, msg string, keyvals ...any)
- func (l *Logger) Warn(_ context.Context, msg string, keyvals ...any)
- func (l *Logger) With(keyvals ...any) bLogger.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger 是基于 Google glog 的日志适配器。
glog 是 Google 开源的 leveled logging 库,广泛用于 gRPC、Kubernetes 等 基础设施项目。它按级别分文件输出日志,支持 V() 细粒度日志级别控制。
注意:glog 不支持原生的结构化键值对,keyvals 会被格式化为 "key=value" 追加到消息中。
Example:
logger := glog.NewLogger() defer logger.Close() logger.Info(ctx, "server started", "port", 8080)
func NewLogger ¶
func NewLogger() *Logger
NewLogger 创建一个 glog 日志记录器。 注意:glog 需要在 main() 中调用 flag.Parse() 才能正常工作。
func (*Logger) Enabled ¶
Enabled 报告给定级别是否会被输出。 glog 的级别由命令行 flag(-v, -stderrthreshold)控制,此处保守返回 true。
Click to show internal directories.
Click to hide internal directories.