logger

package
v0.0.0-...-1225d9a Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "log"
)
View Source
const (
	SUB_LOGGER_KEY = "component"
)

Variables

This section is empty.

Functions

func L

func L() *zerolog.Logger

func Sub

func Sub(name string) *zerolog.Logger

Types

type Config

type Config struct {
	// 0 为打印日志全路径, 默认打印2层路径
	CallerDeep int `toml:"caller_deep" json:"caller_deep" yaml:"caller_deep"  env:"LOG_CALLER_DEEP"`
	// 日志的级别, 默认Debug
	Level zerolog.Level `toml:"level" json:"level" yaml:"level"  env:"LOG_LEVEL"`
	// 开启Trace时, 记录的TraceId名称, 默认trace_id
	TraceFiled string `toml:"TraceFiled" json:"TraceFiled" yaml:"TraceFiled"  env:"LOG_TRACE_FILED"`

	// 控制台日志配置
	Console Console `toml:"console" json:"console" yaml:"console"`
	// 日志文件配置
	File File `toml:"file" json:"file" yaml:"file"`

	ioc.ObjectImpl
	// contains filtered or unexported fields
}

func (*Config) CallerMarshalFunc

func (m *Config) CallerMarshalFunc(pc uintptr, file string, line int) string

func (*Config) Init

func (m *Config) Init() error

func (*Config) Logger

func (m *Config) Logger(name string) *zerolog.Logger

func (*Config) Name

func (m *Config) Name() string

func (*Config) Priority

func (i *Config) Priority() int

Trace加载后才加载日志

func (*Config) SetRoot

func (m *Config) SetRoot(r zerolog.Logger)

func (*Config) TraceLogger

func (m *Config) TraceLogger(name string) *TraceLogger

type Console

type Console struct {
	Enable  bool `toml:"enable" json:"enable" yaml:"enable"  env:"LOG_TO_CONSOLE"`
	NoColor bool `toml:"no_color" json:"no_color" yaml:"no_color"  env:"LOG_CONSOLE_NO_COLOR"`
}

func (*Console) ConsoleWriter

func (c *Console) ConsoleWriter() io.Writer

type File

type File struct {
	// 是否开启文件记录
	Enable bool `toml:"enable" json:"enable" yaml:"enable"  env:"LOG_TO_FILE"`
	// 文件的路径
	FilePath string `toml:"file_path" json:"file_path" yaml:"file_path"  env:"LOG_FILE_PATH"`
	// 单位M, 默认100M
	MaxSize int `toml:"max_size" json:"max_size" yaml:"max_size"  env:"LOG_FILE_MAX_SIZE"`
	// 默认保存 6个文件
	MaxBackups int `toml:"max_backups" json:"max_backups" yaml:"max_backups"  env:"LOG_FILE_MAX_BACKUPS"`
	// 保存多久
	MaxAge int `toml:"max_age" json:"max_age" yaml:"max_age"  env:"LOG_FILE_MAX_AGE"`
	// 是否压缩
	Compress bool `toml:"compress" json:"compress" yaml:"compress"  env:"LOG_FILE_COMPRESS"`
}

func (*File) FileWriter

func (f *File) FileWriter() io.Writer

type TraceLogger

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

func TLogger

func TLogger(name string) *TraceLogger

func (*TraceLogger) Trace

func (t *TraceLogger) Trace(ctx context.Context) *zerolog.Logger

将上下文中的跟踪信息添加到日志记录中

Jump to

Keyboard shortcuts

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