Documentation ¶
Index ¶
- Variables
- func NewZap(name string) (*zap.SugaredLogger, error)
- func NewZapConfig(name string) *zap.Config
- func UnixMilliTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func UnixTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- type LogFunc
- type Logger
- func (c *Logger) AddHook(fn func(e zapcore.Entry) error) *Logger
- func (c *Logger) Autod(dur time.Duration) LogFunc
- func (c *Logger) Debug(args ...interface{})
- func (c *Logger) Debugd() LogFunc
- func (c *Logger) Debugf(template string, args ...interface{})
- func (c *Logger) Debugw(msg string, keysAndValues ...interface{})
- func (c *Logger) Error(args ...interface{})
- func (c *Logger) Errorf(template string, args ...interface{})
- func (c *Logger) Errorw(msg string, keysAndValues ...interface{})
- func (c *Logger) Fatal(args ...interface{})
- func (c *Logger) Fatalf(template string, args ...interface{})
- func (c *Logger) Fatalw(msg string, keysAndValues ...interface{})
- func (c *Logger) Info(args ...interface{})
- func (c *Logger) Infod() LogFunc
- func (c *Logger) Infof(template string, args ...interface{})
- func (c *Logger) Infow(msg string, keysAndValues ...interface{})
- func (c *Logger) Panic(args ...interface{})
- func (c *Logger) Panicf(template string, args ...interface{})
- func (c *Logger) Panicw(msg string, keysAndValues ...interface{})
- func (c *Logger) Skip(skip int) *Logger
- func (c *Logger) Sync() error
- func (c *Logger) Unwrap() *zap.SugaredLogger
- func (c *Logger) Warn(args ...interface{})
- func (c *Logger) Warnd(dur time.Duration) LogFunc
- func (c *Logger) Warnf(template string, args ...interface{})
- func (c *Logger) Warnw(msg string, keysAndValues ...interface{})
- func (c *Logger) With(args ...interface{}) *Logger
- func (c *Logger) Withf(template string, args ...interface{}) *Logger
- func (c *Logger) Withw(keysAndValues ...interface{}) *Logger
Constants ¶
This section is empty.
Variables ¶
var NoLogFunc = func(_ string, _ ...interface{}) {}
Functions ¶
func NewZap ¶
func NewZap(name string) (*zap.SugaredLogger, error)
NewZap returns core logger as sugared logger with default basic config
func NewZapConfig ¶
NewZapConfig read log config from environment default value will be used if env is invalid
func UnixMilliTimeEncoder ¶
func UnixMilliTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func UnixTimeEncoder ¶
func UnixTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wrapper the base zap SugaredLogger for some extra features
func (*Logger) Autod ¶
Autod return a function to log message with elapsed duration, log level could be debug or warn depended on duration time
func (*Logger) Debug ¶
func (c *Logger) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message with prefix.
func (*Logger) Debugw ¶
Debugw logs a message with some additional context with keys and values (prefer for json logs).
func (*Logger) Error ¶
func (c *Logger) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message with prefix.
func (*Logger) Errorw ¶
Errorw logs a message with some additional context with keys and values (prefer for json logs).
func (*Logger) Fatal ¶
func (c *Logger) Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message with prefix.
func (*Logger) Fatalw ¶
Fatalw logs a message with some additional context with keys and values (prefer for json logs).
func (*Logger) Info ¶
func (c *Logger) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message with prefix.
func (*Logger) Infow ¶
Infow logs a message with some additional context with keys and values (prefer for json logs).
func (*Logger) Panic ¶
func (c *Logger) Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message with prefix.
func (*Logger) Panicw ¶
Panicw logs a message with some additional context with keys and values (prefer for json logs).
func (*Logger) Skip ¶
Skip return new instances that increases the number of callers skipped by caller annotation
func (*Logger) Unwrap ¶
func (c *Logger) Unwrap() *zap.SugaredLogger
Unwrap returns core logger instance, so you can use it directly. you can also re-wrap this logger with Wrap function.
func (*Logger) Warn ¶
func (c *Logger) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message with prefix.
func (*Logger) Warnd ¶
Warnd is like Warnf but return a function to log message with duration only if the duration is longer than expected
func (*Logger) Warnw ¶
Warnw logs a message with some additional context with keys and values (prefer for json logs).