log

package
v0.0.0-...-8f0e436 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 13 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...FieldInter)

Debug 输出指定级别日志

func DebugSkip

func DebugSkip(skip int, msg string, fields ...FieldInter)

DebugSkip 输出指定级别日志

skip 提升的堆栈帧数,0-当前函数,1-上一层函数。如果经封装调用该方法,默认2,否则默认1

msg 日志默认输出信息

fields 日志输出对象子集

func Error

func Error(msg string, fields ...FieldInter)

Error 输出指定级别日志

func ErrorSkip

func ErrorSkip(skip int, msg string, fields ...FieldInter)

ErrorSkip 输出指定级别日志

skip 提升的堆栈帧数,0-当前函数,1-上一层函数。如果经封装调用该方法,默认2,否则默认1

msg 日志默认输出信息

fields 日志输出对象子集

func Fatal

func Fatal(msg string, fields ...FieldInter)

Fatal 输出指定级别日志

func FatalSkip

func FatalSkip(skip int, msg string, fields ...FieldInter)

FatalSkip 输出指定级别日志

skip 提升的堆栈帧数,0-当前函数,1-上一层函数。如果经封装调用该方法,默认2,否则默认1

msg 日志默认输出信息

fields 日志输出对象子集

func Fit

func Fit(level string, logDir string, maxSize, maxAge int, utc bool, production bool)

Fit log初始化

level 日志级别(debugLevel/infoLevel/warnLevel/ErrorLevel/panicLevel/fatalLevel)

logDir 日志文件目录

maxSize 每个日志文件保存的最大尺寸 单位:M

maxAge 文件最多保存多少天

utc CST & UTC 时间

production 是否生产环境,在生产环境下控制台不会输出任何日志

func Info

func Info(msg string, fields ...FieldInter)

Info 输出指定级别日志

func InfoSkip

func InfoSkip(skip int, msg string, fields ...FieldInter)

InfoSkip 输出指定级别日志

skip 提升的堆栈帧数,0-当前函数,1-上一层函数。如果经封装调用该方法,默认2,否则默认1

msg 日志默认输出信息

fields 日志输出对象子集

func Panic

func Panic(msg string, fields ...FieldInter)

Panic 输出指定级别日志

func PanicSkip

func PanicSkip(skip int, msg string, fields ...FieldInter)

PanicSkip 输出指定级别日志

skip 提升的堆栈帧数,0-当前函数,1-上一层函数。如果经封装调用该方法,默认2,否则默认1

msg 日志默认输出信息

fields 日志输出对象子集

func Set

func Set(level Level, logDir string, maxSize, maxAge int, utc bool, production bool)

Set log初始化

level 日志级别(debugLevel/infoLevel/warnLevel/ErrorLevel/panicLevel/fatalLevel)

logDir 日志文件目录

maxSize 每个日志文件保存的最大尺寸 单位:M

maxAge 文件最多保存多少天

utc CST & UTC 时间

production 是否生产环境,在生产环境下控制台不会输出任何日志

func Warn

func Warn(msg string, fields ...FieldInter)

Warn 输出指定级别日志

func WarnSkip

func WarnSkip(skip int, msg string, fields ...FieldInter)

WarnSkip 输出指定级别日志

skip 提升的堆栈帧数,0-当前函数,1-上一层函数。如果经封装调用该方法,默认2,否则默认1

msg 日志默认输出信息

fields 日志输出对象子集

Types

type FieldInter

type FieldInter interface {
	GetKey() string
	GetValue() interface{}
}

FieldInter field 接口

func Err

func Err(err error) FieldInter

Err 自定义输出错误

func Errs

func Errs(msg string) FieldInter

Errs 自定义输出错误

func Field

func Field(key string, value interface{}) FieldInter

Field 自定义输出KV对象

func Server

func Server(value string) FieldInter

Server 当前服务

type Level

type Level int8

A Level is a logging priority. Higher levels are more important.

func DebugLevel

func DebugLevel() Level

DebugLevel logs are typically voluminous, and are usually disabled in production.

func ErrorLevel

func ErrorLevel() Level

ErrorLevel logs are high-priority. If an application is running smoothly, it shouldn't generate any error-level logs.

func FatalLevel

func FatalLevel() Level

FatalLevel logs a message, then panics.

func InfoLevel

func InfoLevel() Level

InfoLevel is the default logging priority.

func PanicLevel

func PanicLevel() Level

PanicLevel logs a message, then panics.

func WarnLevel

func WarnLevel() Level

WarnLevel logs are more important than Info, but don't need individual human review.

Jump to

Keyboard shortcuts

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