Documentation ¶
Index ¶
- Constants
- func Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry
- func DPanicEntry(args ...any) *zapcore.CheckedEntry
- func Debug(args ...any)
- func DebugEntry(args ...any) *zapcore.CheckedEntry
- func Debugf(template string, args ...any)
- func Debugw(msg string, fields ...zap.Field)
- func DurationNotify(msg string, v time.Duration, std time.Duration)
- func Error(args ...any)
- func ErrorEntry(args ...any) *zapcore.CheckedEntry
- func Errorf(template string, args ...any)
- func Errorw(msg string, fields ...zap.Field)
- func Fatal(args ...any)
- func FatalEntry(args ...any) *zapcore.CheckedEntry
- func Fatalf(template string, args ...any)
- func Fatalw(msg string, fields ...zap.Field)
- func FileWithLineNum() string
- func Info(args ...any)
- func InfoEntry(args ...any) *zapcore.CheckedEntry
- func Infof(template string, args ...any)
- func Infow(msg string, fields ...zap.Field)
- func Log(lvl zapcore.Level, args ...any)
- func Logf(lvl zapcore.Level, msg string, args ...any)
- func Logw(lvl zapcore.Level, msg string, fields ...zapcore.Field)
- func NewDevelopmentEncoderConfig() zapcore.EncoderConfig
- func NewProductionEncoderConfig() zapcore.EncoderConfig
- func NoCallerDebug(args ...any)
- func NoCallerError(args ...any)
- func NoCallerErrorf(template string, args ...any)
- func NoCallerErrorw(msg string, fields ...zap.Field)
- func NoCallerFatal(args ...any)
- func NoCallerFatalf(template string, args ...any)
- func NoCallerFatalw(msg string, fields ...zap.Field)
- func NoCallerInfo(args ...any)
- func NoCallerPanic(args ...any)
- func NoCallerPanicw(msg string, fields ...zap.Field)
- func NoCallerWarn(args ...any)
- func Panic(args ...any)
- func PanicEntry(args ...any) *zapcore.CheckedEntry
- func Panicf(template string, args ...any)
- func Panicw(msg string, fields ...zap.Field)
- func Printf(template string, args ...any)
- func Println(args ...any)
- func SetDefaultLogger(lf *Config, cores ...zapcore.Core)
- func Sprintln(a ...any) string
- func StackError(args ...any)
- func StackErrorf(template string, args ...any)
- func StackErrorw(msg string, fields ...zap.Field)
- func Sync() error
- func TrimLineBreak(path string) string
- func ValueNotify[T cmp.Ordered](msg string, v T, rangeMin, rangeMax T)
- func Warn(args ...any)
- func WarnEntry(args ...any) *zapcore.CheckedEntry
- func Warnf(template string, args ...any)
- func Warnw(msg string, fields ...zap.Field)
- type Config
- type Logger
- func (l *Logger) AddCore(newCore zapcore.Core) *Logger
- func (l *Logger) AddSkip(skip int) *Logger
- func (l *Logger) DPanic(args ...any)
- func (l *Logger) DPanicf(template string, args ...any)
- func (l *Logger) DPanicw(msg string, fields ...zap.Field)
- func (l *Logger) Debug(args ...any)
- func (l *Logger) Debugf(template string, args ...any)
- func (l *Logger) Debugfw(template string, args ...any) func(...zapcore.Field)
- func (l *Logger) Debugsw(msg string, args ...any)
- func (l *Logger) Debugw(msg string, fields ...zap.Field)
- func (l *Logger) Enabled(ctx context.Context, level slog.Level) bool
- func (l *Logger) Error(args ...any)
- func (l *Logger) ErrorDepth(depth int, args ...any)
- func (l *Logger) Errorf(template string, args ...any)
- func (l *Logger) Errorln(args ...any)
- func (l *Logger) Errorw(msg string, fields ...zap.Field)
- func (l *Logger) Fatal(args ...any)
- func (l *Logger) FatalDepth(depth int, args ...any)
- func (l *Logger) Fatalf(template string, args ...any)
- func (l *Logger) Fatalln(args ...any)
- func (l *Logger) Fatalw(msg string, fields ...zap.Field)
- func (l *Logger) Handle(ctx context.Context, record slog.Record) error
- func (l *Logger) Info(args ...any)
- func (l *Logger) InfoDepth(depth int, args ...any)
- func (l *Logger) Infof(template string, args ...any)
- func (l *Logger) Infofw(template string, args ...any) func(...zapcore.Field)
- func (l *Logger) Infoln(args ...any)
- func (l *Logger) Infow(msg string, fields ...zap.Field)
- func (l *Logger) Named(name string) *Logger
- func (l *Logger) NewSLogger() *slog.Logger
- func (l *Logger) Panic(args ...any)
- func (l *Logger) Panicf(template string, args ...any)
- func (l *Logger) Panicw(msg string, fields ...zap.Field)
- func (l *Logger) Print(args ...any)
- func (l *Logger) Printf(template string, args ...any)
- func (l *Logger) Println(args ...any)
- func (l *Logger) Sugar() *zap.SugaredLogger
- func (l *Logger) V(level int) bool
- func (l *Logger) Warn(args ...any)
- func (l *Logger) Warnf(template string, args ...any)
- func (l *Logger) Warning(args ...any)
- func (l *Logger) WarningDepth(depth int, args ...any)
- func (l *Logger) Warningf(template string, args ...any)
- func (l *Logger) Warningln(args ...any)
- func (l *Logger) Warnw(msg string, fields ...zap.Field)
- func (l *Logger) With(fields ...zap.Field) *Logger
- func (l *Logger) WithAttrs(attrs []slog.Attr) slog.Handler
- func (l *Logger) WithGroup(name string) slog.Handler
- func (l *Logger) WithOptions(opts ...zap.Option) *Logger
- func (l *Logger) Zap() *zap.Logger
- type OutPutPaths
- type RawJson
- type StdErrLevel
- type StdOutLevel
- type ZipConfig
Constants ¶
const ( FieldStack = "stack" FieldApi = "api" FieldSource = "source" FieldResult = "result" FieldParam = "param" FieldFunc = "func" FieldMsg = "msg" FieldPosition = "position" FieldTraceId = "traceId" FieldSpanId = "spanId" FieldKey = "key" FieldValue = "value" FieldInvalid = "invalid" FieldIgnored = "ignored" FieldType = "type" FieldIP = "ip" FieldHostname = "hostname" FieldTime = "time" FieldApp = "app" FieldLevel = "level" FieldCaller = "caller" )
const ( EncodeLevelTypeColor = "color" EncodeLevelTypCapital = "capital" EncodeLevelTypeCapitalColor = "capitalColor" )
Variables ¶
This section is empty.
Functions ¶
func DPanicEntry ¶ added in v0.1.6
func DPanicEntry(args ...any) *zapcore.CheckedEntry
func DebugEntry ¶ added in v0.1.6
func DebugEntry(args ...any) *zapcore.CheckedEntry
func DurationNotify ¶ added in v0.0.20
func ErrorEntry ¶ added in v0.1.6
func ErrorEntry(args ...any) *zapcore.CheckedEntry
func FatalEntry ¶ added in v0.1.6
func FatalEntry(args ...any) *zapcore.CheckedEntry
func FileWithLineNum ¶
func FileWithLineNum() string
FileWithLineNum return the file name and line number of the current file
func InfoEntry ¶ added in v0.1.6
func InfoEntry(args ...any) *zapcore.CheckedEntry
func NewDevelopmentEncoderConfig ¶
func NewDevelopmentEncoderConfig() zapcore.EncoderConfig
func NewProductionEncoderConfig ¶
func NewProductionEncoderConfig() zapcore.EncoderConfig
func NoCallerDebug ¶ added in v0.1.6
func NoCallerDebug(args ...any)
func NoCallerError ¶ added in v0.1.6
func NoCallerError(args ...any)
func NoCallerErrorf ¶ added in v0.1.6
func NoCallerErrorw ¶ added in v0.1.6
func NoCallerFatal ¶ added in v0.1.6
func NoCallerFatal(args ...any)
func NoCallerFatalf ¶ added in v0.1.6
func NoCallerFatalw ¶ added in v0.1.6
func NoCallerInfo ¶ added in v0.1.6
func NoCallerInfo(args ...any)
func NoCallerPanic ¶ added in v0.1.6
func NoCallerPanic(args ...any)
func NoCallerPanicw ¶ added in v0.1.6
func NoCallerWarn ¶ added in v0.1.6
func NoCallerWarn(args ...any)
func PanicEntry ¶ added in v0.1.6
func PanicEntry(args ...any) *zapcore.CheckedEntry
func SetDefaultLogger ¶
func StackErrorf ¶ added in v0.1.6
func StackErrorw ¶ added in v0.1.6
func TrimLineBreak ¶ added in v0.0.36
func ValueNotify ¶ added in v0.0.20
func WarnEntry ¶ added in v0.1.6
func WarnEntry(args ...any) *zapcore.CheckedEntry
Types ¶
type Config ¶
type Config struct { Name string `json:"name,omitempty"` //系统名称namespace.service Development bool DisableCaller bool DisableStacktrace bool Level zapcore.Level `json:"level,omitempty"` Sampling *zap.SamplingConfig `json:"sampling" yaml:"sampling"` OutputPaths OutPutPaths `json:"outputPaths"` ErrorOutputPaths []string // InitialFields is a collection of fields to add to the root logger. InitialFields map[string]interface{} `json:"initialFields" yaml:"initialFields"` zapcore.EncoderConfig EncodeLevelType string `json:"encodeLevelType,omitempty" comment:"capital;capitalColor;color"` }
func NewDevelopmentConfig ¶
func NewProductionConfig ¶
type Logger ¶
func GetNoCallerLogger ¶
func GetNoCallerLogger() *Logger
func GetStackLogger ¶
func GetStackLogger() *Logger
func (*Logger) DPanic ¶
DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)
func (*Logger) DPanicf ¶
DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)
func (*Logger) DPanicw ¶
DPanic logs a message at DPanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
If the logger is in development mode, it then panics (DPanic means "development panic"). This is useful for catching errors that are recoverable, but shouldn't ever happen.
func (*Logger) Debugw ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) ErrorDepth ¶
ErrorDepth logs to ERROR log at the specified depth. Arguments are handled in the manner of fmt.Println.
func (*Logger) Errorw ¶
Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) FatalDepth ¶
FatalDepth logs to FATAL log at the specified depth. Arguments are handled in the manner of fmt.Println.
func (*Logger) Fatalw ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func (*Logger) InfoDepth ¶
InfoDepth logs to INFO log at the specified depth. Arguments are handled in the manner of fmt.Println.
func (*Logger) Infow ¶
Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) NewSLogger ¶
func (*Logger) Panicw ¶
Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then panics, even if logging at PanicLevel is disabled.
func (*Logger) WarningDepth ¶
WarningDepth logs to WARNING log at the specified depth. Arguments are handled in the manner of fmt.Println.
func (*Logger) Warnw ¶
Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) With ¶
With wrap the zap With. Fields added to the child don't affect the parent, and vice versa.
func (*Logger) WithOptions ¶
WithOptions wrap the zap WithOptions, applies the supplied Options, and returns the resulting Logger. It's safe to use concurrently.
type OutPutPaths ¶
type RawJson ¶ added in v0.0.31
type RawJson json.RawMessage
func (RawJson) MarshalJSON ¶ added in v0.0.31
func (RawJson) MarshalLogObject ¶ added in v0.0.31
func (b RawJson) MarshalLogObject(enc zapcore.ObjectEncoder) error