Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func FileWithLineNum() string
- func FromContext(ctx context.Context) (string, bool)
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func NewContext(ctx context.Context) context.Context
- func Panic(args ...interface{})
- func Panicf(template string, args ...interface{})
- func Print(args ...interface{})
- func Printf(template string, args ...interface{})
- func SetDefaultLogger(lf *Config)
- func Sync() error
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- type BytesJson
- type CompleteLogInterface
- type Config
- type IdKey
- type LogInterface
- type Logger
- func (l *Logger) AddCore(newCore zapcore.Core) *Logger
- func (l *Logger) AddSkip(skip int) *Logger
- func (l *Logger) DPanic(args ...interface{})
- func (l *Logger) DPanicf(template string, args ...interface{})
- func (l *Logger) DPanicw(msg string, fields ...zap.Field)
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(template string, args ...interface{})
- func (l *Logger) Debugw(msg string, fields ...zap.Field)
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Errorln(args ...interface{})
- func (l *Logger) Errorw(msg string, fields ...zap.Field)
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(template string, args ...interface{})
- func (l *Logger) Fatalln(args ...interface{})
- func (l *Logger) Fatalw(msg string, fields ...zap.Field)
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(template string, args ...interface{})
- func (l *Logger) Infoln(args ...interface{})
- func (l *Logger) Infow(msg string, fields ...zap.Field)
- func (l *Logger) Named(name string) *Logger
- func (l *Logger) Panic(args ...interface{})
- func (l *Logger) Panicf(template string, args ...interface{})
- func (l *Logger) Panicw(msg string, fields ...zap.Field)
- func (l *Logger) Print(args ...interface{})
- func (l *Logger) Printf(template string, args ...interface{})
- func (l *Logger) Println(args ...interface{})
- func (l *Logger) Sugar() *zap.SugaredLogger
- func (l *Logger) V(level int) bool
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(template string, args ...interface{})
- func (l *Logger) Warning(args ...interface{})
- func (l *Logger) Warningf(template string, args ...interface{})
- func (l *Logger) Warningln(args ...interface{})
- func (l *Logger) Warnw(msg string, fields ...zap.Field)
- func (l *Logger) With(fields ...zap.Field) *Logger
- func (l *Logger) WithOptions(opts ...zap.Option) *Logger
- type OutPutPaths
- type StdErrLevel
- type StdLogInterface
- type StdOutLevel
- type ZapConfig
Constants ¶
const ( Stack = "stack" Interface = "interface" Source = "source" Result = "result" Param = "param" Func = "func" Position = "position" TraceId = "traceId" SpanId = "spanId" Type = "type" )
Variables ¶
This section is empty.
Functions ¶
func FileWithLineNum ¶ added in v1.1.0
func FileWithLineNum() string
FileWithLineNum return the file name and line number of the current file
func FromContext ¶
FromContext returns the User value stored in ctx, if any.
func NewContext ¶
NewContext returns a new Context that carries value u.
func SetDefaultLogger ¶
func SetDefaultLogger(lf *Config)
Types ¶
type BytesJson ¶
type BytesJson json.RawMessage
func (BytesJson) MarshalJSON ¶
func (BytesJson) MarshalLogObject ¶
func (b BytesJson) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*BytesJson) UnmarshalJSON ¶
type CompleteLogInterface ¶ added in v1.1.0
type CompleteLogInterface interface { Debug(v ...interface{}) Debugf(format string, v ...interface{}) Info(v ...interface{}) Infof(format string, v ...interface{}) Warning(v ...interface{}) Warningf(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Panic(v ...interface{}) Panicf(format string, v ...interface{}) }
type Config ¶
type Config struct { Development bool Caller bool Level zapcore.Level OutputPaths OutPutPaths ModuleName string //系统名称namespace.service zapcore.EncoderConfig }
type LogInterface ¶ added in v1.1.0
type LogInterface interface { Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) }
日志接口 go目前的日志库比较混乱,需要一个接口来统一定义,各个库的日志应用该接口实现,方便替换底层实体
type Logger ¶
var (
Default *Logger
)
func GetSkipLogger ¶
func (*Logger) DPanic ¶
func (l *Logger) DPanic(args ...interface{})
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) Debug ¶
func (l *Logger) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message.
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) Error ¶
func (l *Logger) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message.
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) Fatal ¶
func (l *Logger) Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
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) Info ¶
func (l *Logger) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message.
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) Panic ¶
func (l *Logger) Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message, then panics.
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) Warn ¶
func (l *Logger) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message.
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.
type OutPutPaths ¶ added in v1.1.0
type StdErrLevel ¶ added in v1.1.0
type StdLogInterface ¶ added in v1.1.0
type StdLogInterface interface {
Println(args ...interface{})
}