logger

package
v0.0.0-...-a6eea34 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLogFileName 默认日志名称
	DefaultLogFileName = "app.log"
	// DefaultLogDirName 默认日志目录
	DefaultLogDirName = "logs"
	// DefaultLogAsyncTime 异步时间
	DefaultLogAsyncTime = 0
	// DefaultLogAsyncSize 异步输出长度
	DefaultLogAsyncSize = 1 << 10 // 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	OutPut        string // 输出
	Level         string // 日志级别
	Caller        bool   // 是否显示行数
	FileName      string // 日志输出的文件路径,建议是绝对路径
	TimeFormat    string // 日志时间戳格式
	AsyncWriter   bool   // 是否异步写入
	AsyncInterval int    // 定时,单位毫秒
	AsyncSize     int    // 长度
	// contains filtered or unexported fields
}

Config 日志配置

func (*Config) InitWithDefault

func (c *Config) InitWithDefault()

InitWithDefault 配置

func (*Config) NewWriter

func (c *Config) NewWriter() io.Writer

NewWriter 起一个输出

type Interface

type Interface interface {
	Print(v ...interface{})
}

type Logger

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

Logger zerolog logger

func New

func New(config *Config) *Logger

New 返回一个Logger对象

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug logs to Debug log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs to Debug log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Debugln

func (l *Logger) Debugln(args ...interface{})

Debugln logs to Debug log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Errorln

func (l *Logger) Errorln(args ...interface{})

Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...interface{})

Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.

func (*Logger) Fields

func (l *Logger) Fields(fields map[string]interface{}) *Logger

Fields 日志扩展字段

func (*Logger) Hook

func (l *Logger) Hook(h zerolog.Hook) *Logger

Hook 钩子注册

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info logs to INFO log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Infoln

func (l *Logger) Infoln(args ...interface{})

Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Output

func (l *Logger) Output(w io.Writer) *Logger

Output 日志输出

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic logs to Panic log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...interface{})

Panicf logs to Panic log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Panicln

func (l *Logger) Panicln(args ...interface{})

Panicln logs to Panic log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Print

func (l *Logger) Print(args ...interface{})

Print Arguments are handled in the manner of fmt.Print.

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Printf Arguments are handled in the manner of fmt.Printf.

func (*Logger) Println

func (l *Logger) Println(args ...interface{})

Println Arguments are handled in the manner of fmt.Println.

func (*Logger) SetCaller

func (l *Logger) SetCaller(o bool)

SetCaller 设置Caller关闭或开启 caller是一个很耗性能的操作,一般生产环境建议关闭

func (*Logger) V

func (l *Logger) V(level int) bool

V reports whether verbosity level l is at least the requested verbose level.

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn logs to WARNING log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Warning

func (l *Logger) Warning(args ...interface{})

Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...interface{})

Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Warningln

func (l *Logger) Warningln(args ...interface{})

Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Warnln

func (l *Logger) Warnln(args ...interface{})

Warnln logs to WARNING log. Arguments are handled in the manner of fmt.Println.

func (*Logger) ZeroLogger

func (l *Logger) ZeroLogger() zerolog.Logger

ZeroLogger 返回一个 zerolog logger

Jump to

Keyboard shortcuts

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