log

package module
v0.0.0-...-95eac5a Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultLogPath = "./log"
)

Variables

This section is empty.

Functions

func CapitalLevelEncoder

func CapitalLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

CapitalLevelEncoder 自定义等级格式

func FullCallerEncoder

func FullCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)

func ISO8601TimeEncoder

func ISO8601TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

ISO8601TimeEncoder 自定义时间格式

func NewHertzLog

func NewHertzLog(logConfig Config)

func NewKitexLog

func NewKitexLog(logConfig Config)

func NewLumberjackWriteSyncer

func NewLumberjackWriteSyncer(fileName string,
	config *OptionConfig) zapcore.WriteSyncer

func NewRotateWriteSyncer

func NewRotateWriteSyncer(fileName string,
	config *OptionConfig) zapcore.WriteSyncer

func NewWriteSyncer

func NewWriteSyncer(fileName string, config *OptionConfig) zapcore.WriteSyncer

func ShortCallerEncoder

func ShortCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)

func StringDurationEncoder

func StringDurationEncoder(d time.Duration, enc zapcore.PrimitiveArrayEncoder)

StringDurationEncoder 自定义时间格式

Types

type Config

type Config struct {
	Path             string `json:"path"  yaml:"path"`                          //路径
	MaxSize          int    `json:"max_size" yaml:"max_size"`                   //日志的最大大小(M)
	MaxBackups       int    `json:"max_backups"  yaml:"max_backups"`            //日志的最大保存数量
	MaxAge           int    `json:"max_age" yaml:"max_age"`                     //日志文件存储最大天数
	Compress         bool   `json:"compress" yaml:"compress"`                   //是否执行压缩
	OutputMode       int    `json:"output_mode" yaml:"output_mode"`             //输出模式 1:控制台 2:文件 3:控制台和文件都输出
	Suffix           string `json:"suffix" yaml:"suffix"`                       //日志文件后缀名
	RotationDuration int    `json:"rotation_duration" yaml:"rotation_duration"` //文件分隔按照时长切割
	MinSpanLevel     string `json:"min_span_level" yaml:"min_span_level"`       // 日志等级  【trace,debug,info,notice,warn,error,fatal】
	ErrorSpanLevel   string `json:"error_span_level" yaml:"error_span_level"`   // 日志等级  【trace,debug,info,notice,warn,error,fatal】
	RecordStack      bool   `json:"record_stack" yaml:"record_stack"`           //异常是否需要记录堆栈
}

Logger 日志配置

type Level

type Level string
const (
	LevelTrace  Level = "trace"
	LevelDebug  Level = "debug"
	LevelInfo   Level = "info"
	LevelNotice Level = "notice"
	LevelWarn   Level = "warn"
	LevelError  Level = "error"
	LevelFatal  Level = "fatal"
)

func (Level) HLogLevel

func (level Level) HLogLevel() hlog.Level

func (Level) KLogLevel

func (level Level) KLogLevel() klog.Level

KLogLevel return kitex log level

func (Level) ZapLevel

func (level Level) ZapLevel() zapcore.Level

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithCompress

func WithCompress(compress bool) Option

func WithMaxAge

func WithMaxAge(maxAge int) Option

func WithMaxBackups

func WithMaxBackups(maxBackups int) Option

func WithMaxSize

func WithMaxSize(maxSize int) Option

func WithOutputMode

func WithOutputMode(outputMode int) Option

func WithPath

func WithPath(path string) Option

func WithRotationDuration

func WithRotationDuration(rotationDuration time.Duration) Option

func WithSuffix

func WithSuffix(suffix string) Option

type OptionConfig

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

func DefaultOptionConfig

func DefaultOptionConfig() *OptionConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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