mylogger

package
v0.0.0-...-4b0ee74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const (
	XRequestIDKey = "X-Request-ID"
	RequestIdKey  = "request_id"
)

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, msg string, fields ...zap.Field)

func DebugEnable

func DebugEnable() bool

func Debugf

func Debugf(ctx context.Context, template string, args ...interface{})

func Error

func Error(ctx context.Context, msg string, fields ...zap.Field)

func Errorf

func Errorf(ctx context.Context, template string, args ...interface{})

func Fatal

func Fatal(ctx context.Context, msg string, fields ...zap.Field)

func Fatalf

func Fatalf(ctx context.Context, template string, args ...interface{})

func GetRequestID

func GetRequestID(ctx context.Context) string

func GetWriter

func GetWriter(filename string) io.Writer

func GetZapLogger

func GetZapLogger() *zap.Logger

func Info

func Info(ctx context.Context, msg string, fields ...zap.Field)

func Infof

func Infof(ctx context.Context, template string, args ...interface{})

func Init

func Init(cfg *LoggerCfg) error

func Warn

func Warn(ctx context.Context, msg string, fields ...zap.Field)

func Warnf

func Warnf(ctx context.Context, template string, args ...interface{})

func WhitIsCompress

func WhitIsCompress(isCompress bool) optionFun

func WhitIsConsole

func WhitIsConsole(isConsole bool) optionFun

func WhitLevel

func WhitLevel(level string) optionFun

func WhitLoggingDir

func WhitLoggingDir(dir string) optionFun

func WhitMaxAge

func WhitMaxAge(maxAge int) optionFun

func WhitMaxBackup

func WhitMaxBackup(maxBackup int) optionFun

func WhitMaxSize

func WhitMaxSize(maxSize int) optionFun

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewZap

func NewZap() (*Logger, error)

func (*Logger) Debug

func (m *Logger) Debug(msg string, fields ...zap.Field)

func (*Logger) Debugf

func (m *Logger) Debugf(template string, args ...interface{})

func (*Logger) Error

func (m *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) Errorf

func (m *Logger) Errorf(template string, args ...interface{})

func (*Logger) Fatal

func (m *Logger) Fatal(msg string, fields ...zap.Field)

func (*Logger) Fatalf

func (m *Logger) Fatalf(template string, args ...interface{})

func (*Logger) Info

func (m *Logger) Info(msg string, fields ...zap.Field)

func (*Logger) Infof

func (m *Logger) Infof(template string, args ...interface{})

func (*Logger) Warn

func (m *Logger) Warn(msg string, fields ...zap.Field)

func (*Logger) Warnf

func (m *Logger) Warnf(template string, args ...interface{})

type LoggerCfg

type LoggerCfg struct {
	Level      string `yaml:"level"`
	LoggingDir string `yaml:"dir"`
	IsCompress bool   `yaml:"is_compress"`
	IsConsole  bool   `yaml:"is_console"`
	MaxSize    int    `yaml:"max_size"`
	MaxAge     int    `yaml:"max_age"`
	MaxBackup  int    `yaml:"max_backup"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL