Documentation ¶
Index ¶
- Constants
- func BuildAndSetBgLogger(config Config)
- func SetBgLogger(logger *Core)
- func WithKeyValue(ctx context.Context, key, value string) context.Context
- func WithLogger(ctx context.Context, logger *Core) context.Context
- func WithZapOptions(ctx context.Context, option ...zap.Option) context.Context
- type Config
- type Core
- func (c *Core) DPanic(msg string, fields ...zap.Field)
- func (c *Core) DPanicf(format string, v ...interface{})
- func (c *Core) Debug(msg string, fields ...zap.Field)
- func (c *Core) Debugf(format string, v ...interface{})
- func (c *Core) Error(msg string, fields ...zap.Field)
- func (c *Core) Errorf(format string, v ...interface{})
- func (c *Core) Fatal(msg string, fields ...zap.Field)
- func (c *Core) Fatalf(format string, v ...interface{})
- func (c *Core) Info(msg string, fields ...zap.Field)
- func (c *Core) Infof(format string, v ...interface{})
- func (c *Core) Panic(msg string, fields ...zap.Field)
- func (c *Core) Panicf(format string, v ...interface{})
- func (c *Core) Warn(msg string, fields ...zap.Field)
- func (c *Core) Warnf(format string, v ...interface{})
- type Levels
Constants ¶
const ContextKey = contextKey(1)
const ( // ScopeKey to distinguish scope of logs. Convenient for searching log. // e.g. scope: process-receipt // // log.WithKeyValue(ctx, log.ScopeKey, "process-receipt") ScopeKey = "scope" )
Variables ¶
This section is empty.
Functions ¶
func BuildAndSetBgLogger ¶
func BuildAndSetBgLogger(config Config)
func WithKeyValue ¶
WithKeyValue attach key/value to logger
func WithLogger ¶
WithLogger add logger to context
Types ¶
type Config ¶
func DevelopmentAndJSONConfig ¶
func DevelopmentAndJSONConfig() Config
DevelopmentAndJSONConfig set background logger to development mode with JSON style.
func DevelopmentAndTextConfig ¶
func DevelopmentAndTextConfig() Config
DevelopmentAndTextConfig set background logger to development mode with text style.
func ProductionAndJSONConfig ¶
func ProductionAndJSONConfig() Config
ProductionAndJSONConfig set background logger to production mode with JSON style.
func ProductionAndTextConfig ¶
func ProductionAndTextConfig() Config
ProductionAndTextConfig set background logger to production mode with text style.
type Core ¶
func BuildLogger ¶
func Logger ¶
Logger gets a contextual logger from current context. contextual logger will output common fields from context.
func (*Core) DPanic ¶
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 (*Core) DPanicf ¶
DPanicf formats according to a format specifier and logs the formatted message at DPanicLevel.
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 (*Core) Debug ¶
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 (*Core) Debugf ¶
Debugf formats according to a format specifier and logs the formatted message at DebugLevel.
func (*Core) Error ¶
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 (*Core) Errorf ¶
Errorf formats according to a format specifier and logs the formatted message at ErrorLevel.
func (*Core) Fatal ¶
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 (*Core) Fatalf ¶
Fatalf formats according to a format specifier and logs the formatted message at FatalLevel.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func (*Core) Info ¶
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 (*Core) Infof ¶
Infof formats according to a format specifier and logs the formatted message at InfoLevel.
func (*Core) Panic ¶
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 (*Core) Panicf ¶
Panicf formats according to a format specifier and logs the formatted message at PanicLevel.
The logger then panics, even if logging at PanicLevel is disabled.
type Levels ¶
type Levels map[string]*zap.AtomicLevel
func NewLogLevels ¶
NewLogLevels return a new log levels
func (*Levels) Get ¶
func (l *Levels) Get() *zap.AtomicLevel
func (*Levels) GetWithScope ¶
func (l *Levels) GetWithScope(scope string) *zap.AtomicLevel