diff --git a/interfaces.go b/interfaces.go index ef0f8ec..7132de5 100644 --- a/interfaces.go +++ b/interfaces.go @@ -9,3 +9,14 @@ type LoggerInterface interface { Error(ctx context.Context, args ...any) Errorf(ctx context.Context, format string, args ...any) } + +// Debug 使用的日志接口 +// Waring 警告的日志接口 + +type DebugLoggerInterface interface { + LoggerInterface + Debug(ctx context.Context, args ...any) + Debugf(ctx context.Context, format string, args ...any) + Warn(ctx context.Context, args ...any) + Warnf(ctx context.Context, format string, args ...any) +} \ No newline at end of file diff --git a/loggerx.go b/loggerx.go index 8e3c925..bc61948 100644 --- a/loggerx.go +++ b/loggerx.go @@ -129,6 +129,24 @@ func (l *Logger) Errorf(ctx context.Context, format string, v ...any) { l.logger(ctx, "error", s) } +func (l *Logger) Debug(ctx context.Context, v ...any) { + l.logger(ctx, "debug", v...) +} + +func (l *Logger) Debugf(ctx context.Context, format string, v ...any) { + s := fmt.Sprintf(format, v...) + l.logger(ctx, "debug", s) +} + +func (l *Logger) Warn(ctx context.Context, v ...any) { + l.logger(ctx, "warn", v...) +} + +func (l *Logger) Warnf(ctx context.Context, format string, v ...any) { + s := fmt.Sprintf(format, v...) + l.logger(ctx, "warn", s) +} + // 添加固定的内容 // func (l *Logger) ContextWithFields(ctx context.Context, v ...any) { // l.logger(ctx, "add", v...) diff --git a/options.go b/options.go index 6b72605..e91f929 100644 --- a/options.go +++ b/options.go @@ -60,6 +60,8 @@ func SetTraceField(traceField string) Option { } } +// 1.info 2.error 3.debug 4.warn 5.fatal + // 附加字段 func SetExpandData(key string, value string) Option { return func(o *loggerOption) {