添加业务模式
This commit is contained in:
@@ -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)
|
||||
}
|
||||
+18
@@ -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...)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user