package
1.4.5
Repository: https://github.com/go-eyas/toolkit.git
Documentation: pkg.go.dev

# README

日志库

  • 日志滚动,保存15天内的日志,每1小时(整点)分割一次日志(可配置)
  • 日志文件分级保存 debug, info, error
  • 可选是否输出日志到控制台
  • 支持输出打日志的文件文件行号

使用

只支持单例log


// 使用前必须先初始化
log.Init(&log.LogConfig{
	Level:   "info", // 日志级别
	Path:    ".runtime/logs", // 日志保存路径
	Name:    "api", // 日志文件名
	Console: true, // 是否把日志输出到控制台
	Caller: true, // 是否输出打日志的文件和行号,会影响性能
	MaxAge: time.Hour * 24 * 15, // 保存多久的日志,默认15天
	RotationTime: time.Hour, // 多久分割一次日志,默认一小时
    SplitLevel: true, // 是否把不同级别的日志打到不同文件,如果为false 则所有级别日志打到同一个文件
})

log.Debug("is debug log")
log.Info("is info log")
log.Warn("is warn log")
log.Error("is error log")
log.Panic("is panic log")

log.Debugf("is debug log %s %d %v", "string", 123, map[string]string{"test": "hello"})
log.Infof("is info log %s %d %v", "string", 123, map[string]string{"test": "hello"})
log.Warnf("is warn log %s %d %v", "string", 123, map[string]string{"test": "hello"})
log.Errorf("is error log %s %d %v", "string", 123, map[string]string{"test": "hello"})
log.Fatalf("is fatal log %s %d %v", "string", 123, map[string]string{"test": "hello"})
log.Panicf("is panic log %s %d %v", "string", 123, map[string]string{"test": "hello"})

godoc

API 文档

# Functions

Debug 打日志.
Debugf 格式化日志.
Error 打日志.
Errorf 格式化日志.
Fatalf 格式化日志.
Info 打日志.
Infof 格式化日志.
Init 初始化日志库.
Panic 打日志.
Panicf 格式化日志.
Warn 打日志.
Warnf 格式化日志.

# Variables

No description provided by the author
No description provided by the author

# Structs

LogConfig 日志配置.