代码拉取完成,页面将自动刷新
package elog
import (
"fmt"
"gitee.com/xxc_opensource/elog/core"
)
// TODO: 需要自定义日期格式,日志级别,输出格式(Str||JsonStr||CustomFormatStr)
type LogLevel byte
const (
Debug LogLevel = 1 << iota
Info
Warn
Error
Fatal
Panic
)
type LogFormat byte
const (
DefaultFormat LogFormat = 1 << iota
JSONFormat
CustomFormat
)
type Elog struct {
Level LogLevel
Format LogFormat
core *core.Core
}
// NewElog 创建一个日志组件
func NewElog(logLevel LogLevel, core *core.Core) *Elog {
elog := &Elog{
Level: logLevel,
core: core,
}
elog.core.Start()
return elog
}
// Close 关闭日志组件
func (el *Elog) Close() {
el.core.Close()
}
func (el *Elog) Debug(format string, a ...any) {
if el.Level > Debug {
return
}
el.core.Write([]byte(fmt.Sprintf(format, a...)))
}
func (el *Elog) Info(format string, a ...any) {
if el.Level > Info {
return
}
el.core.Write([]byte(fmt.Sprintf(format, a...)))
}
func (el *Elog) Warn(format string, a ...any) {
if el.Level > Warn {
return
}
el.core.Write([]byte(fmt.Sprintf(format, a...)))
}
func (el *Elog) Error(format string, a ...any) {
if el.Level > Error {
return
}
el.core.Write([]byte(fmt.Sprintf(format, a...)))
}
func (el *Elog) Fatal(format string, a ...any) {
if el.Level > Fatal {
return
}
el.core.Write([]byte(fmt.Sprintf(format, a...)))
}
func (el *Elog) Panic(format string, a ...any) {
if el.Level > Panic {
return
}
el.core.Write([]byte(fmt.Sprintf(format, a...)))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。