Documentation ¶
Index ¶
- Constants
- Variables
- func All(format string, v ...interface{})
- func DaySplitSuffix(unix ...int64) string
- func Debug(format string, v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(format string, v ...interface{})
- func Fatalf(format string, v ...interface{})
- func FileClose()
- func GetFileSiz()
- func GetLogLevel() string
- func GetPrintTo() string
- func GetWriteModel() string
- func HourSplitSuffix(unix ...int64) string
- func Info(format string, v ...interface{})
- func Infof(format string, v ...interface{})
- func InitSlog()
- func Off(format string, v ...interface{})
- func Printf(lv LogLevel, format string, v ...interface{})
- func Println(lv LogLevel, format string, v ...interface{})
- func RunPath(skip int) (filepath, line, funcName string)
- func TimeNanoToString(unix ...int64) string
- func TimeToString(unix ...int64) string
- func Warn(format string, v ...interface{})
- func Warnf(format string, v ...interface{})
- func WriteSlog(lv LogLevel, body string)
- type LogLevel
- type WriteModel
Constants ¶
View Source
const ( // Console 输出至控制台 Console printOut = iota // File 输出至日志文件 File )
View Source
const ( Day cut = iota Hour )
View Source
const DefWriteMaxWaitTime time.Duration = 2 * time.Second
DefWriteMaxWaitTime 默认的日志写入最大等待时长 当存在连续不断的日志进入缓存队列时 向文件写入记录并不执行关闭操作 若无写入行为时间超过该时间,执行文件关闭
Variables ¶
View Source
var DefLogLevel = INFO
DefLogLevel 默认的日志级别
View Source
var DefPrint printOut = Console
DefPrint 输出方向 设置一个全局的输出方向, 但函数Printf 不受此参数控制,Printf()始终将日志输出到控制台
View Source
var DefSplit cut = Day
DefSplit 日志分割模式
View Source
var Prefix = ""
Prefix 日志前缀--可携带路径参数,如: “log/slog” 日志将会输出到 项目根目录/log/slog20220801.log
Functions ¶
func DaySplitSuffix ¶ added in v0.0.9
func GetFileSiz ¶ added in v0.0.8
func GetFileSiz()
func GetLogLevel ¶ added in v0.0.8
func GetLogLevel() string
func GetPrintTo ¶ added in v0.0.8
func GetPrintTo() string
func GetWriteModel ¶ added in v0.0.8
func GetWriteModel() string
func HourSplitSuffix ¶ added in v0.0.9
func TimeNanoToString ¶
TimeNanoToString 获取当前时间转为人类可读模式--纳秒
Types ¶
type WriteModel ¶
type WriteModel int
WriteModel 日志写入模式 当前提供结构化与单行写入
const ( // WriteSingleLine 单行模式 所有信息都保存到一行 WriteSingleLine WriteModel = iota // WriteStructured 结构化模式 WriteStructured )
var DefWriteModel WriteModel = WriteStructured
DefWriteModel 默认的日志写入模式
Click to show internal directories.
Click to hide internal directories.