logger

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 16 Imported by: 7

README

logger

logger包是日志管理包

base:
  logger:
    # 日志root级别:trace/debug/info/warn/error/fatal/panic,默认:info
    level: info
    time:
      # 时间格式,time包中的内容
      format: time.RFC3339
    # 日志颜色
    color:
      # 启用:true/false,默认:false
      enable: false
    split:
      # 日志是否启用切分:true/false,默认false
      enable: false
      # 日志拆分的单位:MB
      size: 300
    max:
      ## 日志文件最大保留天数
      history: 7
    ## 日志文件目录,默认工程目录的logs文件夹
    dir: ./logs/
    
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(format string, v ...any)

func Debug

func Debug(format string, v ...any)

func Error

func Error(format string, v ...any)

func Fatal added in v1.0.13

func Fatal(format string, v ...any)

func Info

func Info(format string, v ...any)

func InitLog added in v0.7.0

func InitLog(appName string, cfg *LoggerConfig)

InitLog create a root logger. it will write to console and multiple file by level. note: default set root logger level is info it provides custom log with CustomizeFiles,if it match any caller's name ,log's level will be setting debug and output

func Panic added in v1.0.13

func Panic(format string, v ...any)

func SetGlobalLevel added in v0.7.0

func SetGlobalLevel(strLevel string)

SetGlobalLevel sets the global override for log level. If this values is raised, all Loggers will use at least this value.

To globally disable logs, set zerolog.GlobalLevel to Disabled.

func Warn

func Warn(format string, v ...any)

Types

type FileLevelWriter added in v0.9.0

type FileLevelWriter struct {
	*os.File
	// contains filtered or unexported fields
}

func (*FileLevelWriter) WriteLevel added in v0.9.0

func (lw *FileLevelWriter) WriteLevel(level zerolog.Level, p []byte) (n int, err error)

type Handler added in v1.0.13

type Handler interface {
	//Dup2 THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
	Dup2(newfd *FileLevelWriter, oldfd *os.File) (err error)
}

type LoggerConfig added in v1.0.10

type LoggerConfig struct {
	Level string `yaml:"level"`
	Time  struct {
		Format string `yaml:"format"`
	} `yaml:"time"`
	Color struct {
		Enable bool `yaml:"enable"`
	} `yaml:"color"`
	Split struct {
		Enable bool  `yaml:"enable"`
		Size   int64 `yaml:"size"`
	} `yaml:"split"`
	Dir string `yaml:"dir"`
	Max struct {
		History int `yaml:"history"`
	} `yaml:"max"`
	Panic bool `yaml:"panic"`
}

type Strategy added in v1.0.13

type Strategy struct {
}

func (Strategy) Dup2 added in v1.0.13

func (s Strategy) Dup2(newfd *FileLevelWriter, oldfd *os.File) (err error)

Jump to

Keyboard shortcuts

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