logger

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT, MIT Imports: 8 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{})

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

func Debug

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

Debug debug日志直接输出到终端

func Error

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

func Fatal

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

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

func Info

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

func InitLogger

func InitLogger()

func LogCompress

func LogCompress(b bool)

LogCompress日志是否压缩

func LogLevel

func LogLevel(lvl string)

LogLevel 日志级别

func LogSugar

func LogSugar() *zap.SugaredLogger

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

func MaxAge

func MaxAge(n int)

MaxAge 日志保留时间

func MaxSize

func MaxSize(n int)

MaxSize 日志大小 mb

func Panic

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

Panic 下面的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)

SetLogDir 日志存放目录

func SetLogFile

func SetLogFile(fileName string)

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

func SetLogTraceFile added in v1.8.4

func SetLogTraceFile(b bool)

SetLogTraceFile 日志是否需要文件名和行数

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