logger

package
v0.0.0-...-5a65518 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LogTypeZap    = "zap"
	LogTypeLogrus = "logrus"
)

Variables

This section is empty.

Functions

func InitLog

func InitLog(c Config)

Types

type Config

type Config struct {
	Level       string `json:",default=Info,options=Debug|Info|Warn|Error|Panic|fatal"` //日志级别,默认为info
	FilePath    string `json:",default=/log,optional"`                                  //日志文件路径
	LogType     string `json:",default=zap,options=logrus|zap,optional"`                //日志类型,默认zap,目前支持zap和logrus
	ServiceName string `json:",optional"`                                               //所属服务
	MaxSize     int    `json:",default=10,optional"`                                    //日志文件最大数量
	MaxAge      int    `json:",default=30,optional"`                                    //最大保留天数
	BackupNum   int    `json:",default=100,optional"`                                   //最大保留日志文件数量
	Compress    bool   `json:",default=false,optional"`                                 //是否压缩
}

type DefaultFieldHook

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

func (*DefaultFieldHook) Fire

func (hook *DefaultFieldHook) Fire(entry *logrus.Entry) error

func (*DefaultFieldHook) Levels

func (hook *DefaultFieldHook) Levels() []logrus.Level

type ILog

type ILog interface {
	Info(ctx context.Context, v ...interface{})
	Infof(ctx context.Context, format string, v ...interface{})
	Error(ctx context.Context, v ...interface{})
	Errorf(ctx context.Context, format string, v ...interface{})
	Panic(ctx context.Context, v ...interface{})
	Panicf(ctx context.Context, format string, v ...interface{})
	Warn(ctx context.Context, v ...interface{})
	Warnf(ctx context.Context, format string, v ...interface{})
	Debug(ctx context.Context, v ...interface{})
	Debugf(ctx context.Context, format string, v ...interface{})

	WithField(field, value string)
	// contains filtered or unexported methods
}

type KeyPair

type KeyPair struct {
	Key string      `json:"key"`
	Val interface{} `json:"val"`
}

type Logger

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

func GetLogger

func GetLogger() *Logger

func (*Logger) Close

func (l *Logger) Close(f func())

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, v ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(ctx context.Context, format string, v ...interface{})

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(ctx context.Context, format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(ctx context.Context, format string, v ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(ctx context.Context, v ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(ctx context.Context, format string, v ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, v ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(ctx context.Context, format string, v ...interface{})

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) *Logger

func (*Logger) WithField

func (l *Logger) WithField(key string, val any) *Logger

Jump to

Keyboard shortcuts

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