glog

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

* * package glog 将日志直接落地到磁盘,支持每天流动式日志记录 * 对于需要实时展示日志的业务,建议用这个glog库 * 相比logger库基于zap来说,速度相对要慢一点

  • 每天流动式日志实现
  • 操作日志记录到文件,支持info,error,debug,notice,alert等
  • 写日志文件的时候,采用乐观锁方式对文件句柄进行加锁
  • 等级参考php Monolog/logger.php
  • 日志切割机制参考lumberjack包实现
  • json encode采用jsoniter库快速json encode处理
  • 支持Debug,Info,Error,Warn等方法

Index

Constants

View Source
const (
	EMERGENCY = "emergency" // 严重错误: 导致系统崩溃无法使用
	ALTER     = "alter"     // 警戒性错误: 必须被立即修改的错误
	CRITICAL  = "critical"  // 临界值错误: 超过临界值的错误,例如一天24小时,而输入的是25小时这样
	ERR       = "error"     // 一般错误:比如类型错误,数据库连接不上等等
	WARN      = "warn"      // 警告性错误: 需要发出警告的错误
	NOTICE    = "notice"    // 通知: 程序可以运行但是还不够完美的错误
	INFO      = "info"      // 信息: 程序输出信息
	DEBUG     = "debug"     // 调试: 调试信息
)

日志级别 从上到下,由高到低

Variables

View Source
var LogLevelMap = map[string]int{
	EMERGENCY: 600,
	ALTER:     550,
	CRITICAL:  500,
	ERR:       400,
	WARN:      300,
	NOTICE:    250,
	INFO:      200,
	DEBUG:     100,
}

Functions

func Alter

func Alter(v interface{}, options map[string]interface{})

Alter alter log.

func Critical

func Critical(v interface{}, options map[string]interface{})

Critical critical log.

func Debug

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

Debug debug log.

func Emergency

func Emergency(v interface{}, options map[string]interface{})

Emergency emergency log.

func Error

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

Error error log.

func FileName

func FileName(name string)

FileName 指定日志文件名称

func Info

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

Info info log.

func LogSize

func LogSize(n int64)

LogSize 日志大小,单位mb

func LogSplit

func LogSplit(b bool)

LogSplit 日志分割设置

func Notice

func Notice(v interface{}, options map[string]interface{})

Notice notice log.

func RecoverLog

func RecoverLog()

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

func SetLogDir

func SetLogDir(dir string)

SetLogDir 日志存放目录

func SetLogTmZone

func SetLogTmZone(timezone string)

SetLogTmZone 设置日志记录时区

func TraceFileLine

func TraceFileLine(b bool)

TraceFileLine 是否开启记录文件名和行数

func Warn

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

Warn warn log.

Types

This section is empty.

Jump to

Keyboard shortcuts

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