logger

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2019 License: MIT, MIT Imports: 9 Imported by: 10

README

golang logger

基于uber zap封装而成的logger模块,可用于go应用中记录操作日志。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DPanic

func DPanic(msg string, options map[string]interface{})

调试模式下的panic,程序不退出,继续运行

func Debug

func Debug(msg string, options map[string]interface{})

debug日志直接输出到终端

func Error

func Error(msg string, options map[string]interface{})

func Fatal

func Fatal(msg string, options map[string]interface{})

抛出致命错误,然后退出程序

func Info

func Info(msg string, options map[string]interface{})

func InitLogger

func InitLogger()

func LogCompress

func LogCompress(b bool)

func LogLevel

func LogLevel(lvl string)

func LogSugar

func LogSugar() *zap.SugaredLogger

sugar语法糖,支持简单的msg信息打印 支持Debug,Info,Error,Panic,Warn,Fatal等方法

func MaxAge

func MaxAge(n int)

func MaxSize

func MaxSize(n int)

func Panic

func Panic(msg string, options map[string]interface{})

下面的panic,fatal一般不建议使用,除非不可恢复的panic或致命错误程序必须退出 抛出panic的时候,先记录日志,然后执行panic,退出当前goroutine

func Recover added in v1.1.9

func Recover()

Recover 异常捕获处理,对于异常或者panic进行捕获处理,记录到日志中,方便定位问题

func SetLogDir added in v1.1.8

func SetLogDir(dir string)

日志存放目录

func SetLogFile

func SetLogFile(fileName string)

设置日志文件路径,如果日志文件不存在zap会自动创建文件

func Stack added in v1.1.9

func Stack() []byte

Stack 获取完整的堆栈信息 Stack returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.

func Warn

func Warn(msg string, options map[string]interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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