Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerExample ¶
func LoggerExample()
func LoggerV1Example ¶
func LoggerV1Example()
func LoggerV2Example ¶
func LoggerV2Example()
func SetGlobalLogger ¶
func SetGlobalLogger(l LoggerV1)
Types ¶
type Logger ¶
type Logger interface { Debug(msg string, args ...any) Info(msg string, args ...any) Warn(msg string, args ...any) Error(msg string, args ...any) }
实践1
type LoggerV1 ¶
type LoggerV1 interface { Debug(msg string, args ...Field) Info(msg string, args ...Field) Warn(msg string, args ...Field) Error(msg string, args ...Field) }
实践2
var GL LoggerV1 = &NoOpLogger{}
func NewNoOpLogger ¶
func NewNoOpLogger() LoggerV1
type LoggerV2 ¶
type LoggerV2 interface { // args 必须是偶数,并且按照 key-value, key-value 来组织 Debug(msg string, args ...any) Info(msg string, args ...any) Warn(msg string, args ...any) Error(msg string, args ...any) }
实践3
type NoOpLogger ¶
type NoOpLogger struct { }
func (*NoOpLogger) Debug ¶
func (n *NoOpLogger) Debug(msg string, args ...Field)
func (*NoOpLogger) Error ¶
func (n *NoOpLogger) Error(msg string, args ...Field)
func (*NoOpLogger) Info ¶
func (n *NoOpLogger) Info(msg string, args ...Field)
func (*NoOpLogger) Warn ¶
func (n *NoOpLogger) Warn(msg string, args ...Field)
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
func NewZapLogger ¶
Click to show internal directories.
Click to hide internal directories.