Documentation ¶
Index ¶
- Constants
- Variables
- func All(format string, v ...interface{})
- 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 FileNameSuffix(c cut, unix ...int64) string
- func GetFileSiz(unit size) int64
- func GetLogLevel() string
- func GetPrintTo() string
- func GetWriteModel() string
- func Info(format string, v ...interface{})
- func Infof(format string, v ...interface{})
- func InitLogFile()
- func Off()
- func PW(b []byte) (n int, err error)
- func Panic(format string, v ...interface{})
- func Panicf(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) *slog
- type InputWriter
- type LogOutWrite
- type OutWriter
- type WriteModel
- type XSlog
Constants ¶
View Source
const ( ALL logLevel = iota DEBUG INFO WARN ERROR FATAL PANIC OFF )
View Source
const ( // Console 输出至控制台 Console printOut = iota // File 输出至日志文件 File // Other 输出向其他IO接口 Other )
View Source
const ( Day cut = iota Hour )
View Source
const ( Kb size = 1024 Mb = 1024 * Kb Gb = 1024 * Mb Tb = 1024 * Gb )
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 LogFilePath = ""
LogFilePath 日志文件输出路径 参考路径为项目根目录 无需添加结尾的 "/" 程序会补全 “log” 日志将会输出到 项目根目录 log/20220801.log
View Source
var LogFilePrefix = ""
LogFilePrefix 日志前缀--可携带路径参数,如: “slog” 日志将会输出到 slog20220801.log
Functions ¶
func FileNameSuffix ¶
FileNameSuffix 根据时间戳计算对应格式的字符串
func GetFileSiz ¶ added in v0.0.8
func GetFileSiz(unit size) int64
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 InitLogFile ¶ added in v0.1.0
func InitLogFile()
func TimeNanoToString ¶
TimeNanoToString 获取当前时间转为人类可读模式--纳秒
Types ¶
type InputWriter ¶ added in v0.1.2
type InputWriter struct{}
type LogOutWrite ¶ added in v0.1.0
type LogOutWrite struct {
// contains filtered or unexported fields
}
LogOutWrite 向日志文件输出
func NewLogFile ¶ added in v0.1.0
func NewLogFile() (log *LogOutWrite, err error)
func (*LogOutWrite) FileName ¶ added in v0.1.0
func (l *LogOutWrite) FileName(timestamp int64) string
func (LogOutWrite) Name ¶ added in v0.1.0
func (l LogOutWrite) Name() string
func (*LogOutWrite) Size ¶ added in v0.1.0
func (l *LogOutWrite) Size(unit size) int64
func (*LogOutWrite) Sync ¶ added in v0.1.0
func (l *LogOutWrite) Sync() error
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.