-
-func (l *Logger)DPanicf(formatMsg string, a ...interface{}) {
- msg := fmt.Sprintf(formatMsg, a...)
- l.Logger.DPanic(msg, zap.Any("mdc", l.getTimeStampMdc()))
-}
-
-func initLoggerByLevel(l zapcore.Level) (*zap.Logger, error) {
- cfg := zap.Config{
- Encoding: "json",
- Level: zap.NewAtomicLevelAt(l),
- OutputPaths: []string{"stdout"},
- ErrorOutputPaths: []string{"stderr"},
- EncoderConfig: zapcore.EncoderConfig{
- MessageKey: "msg",
-
- LevelKey: "crit",
- EncodeLevel: zapcore.CapitalLevelEncoder,
-
- TimeKey: "ts",
- EncodeTime: epochMillisIntegerTimeEncoder,
-
- CallerKey: "id",
- EncodeCaller: xAppMockCallerEncoder,
- },
- }
- return cfg.Build()
-}
-
-func xAppMockCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
- enc.AppendString("xAppMock")
-}
-
-func epochMillisIntegerTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
- nanos := t.UnixNano()
- millis := int64(nanos) / int64(time.Millisecond)
- enc.AppendInt64(millis)
-}
-