Documentation ¶
Index ¶
- Variables
- func Blue(text any) string
- func ClearColor(content string) string
- func ClearLogBuffer(logIns core.ILog)
- func CloseBuffer()
- func ComponentInfo(appName string, contents ...any)
- func ComponentInfof(appName string, format string, a ...any)
- func Critical(contents ...any)
- func Criticalf(format string, a ...any)
- func Debug(contents ...any)
- func Debugf(format string, a ...any)
- func Error(contents ...any) error
- func ErrorIfExists(err error)
- func Errorf(format string, a ...any) error
- func Green(text any) string
- func Info(contents ...any)
- func Infof(format string, a ...any)
- func InitLog() core.ILog
- func LoadLogBuffer(logIns core.ILog)
- func Panic(contents ...any)
- func Panicf(format string, a ...any)
- func Print(contents ...any)
- func Printf(format string, a ...any)
- func Println(contents ...any)
- func Red(text any) string
- func ReplaceBlue(strSource string, text string) string
- func ReplaceBlues(strSource string, texts ...string) string
- func ReplaceGreen(strSource string, text string) string
- func ReplaceGreens(strSource string, texts ...string) string
- func ReplaceRed(strSource string, text string) string
- func ReplaceReds(strSource string, texts ...string) string
- func ReplaceYellow(strSource string, text string) string
- func ReplaceYellows(strSource string, texts ...string) string
- func Trace(contents ...any)
- func Tracef(format string, a ...any)
- func Warning(contents ...any)
- func Warningf(format string, a ...any)
- func Yellow(text any) string
- type CompositionLogger
- func (r *CompositionLogger) Critical(contents ...any)
- func (r *CompositionLogger) Criticalf(format string, a ...any)
- func (r *CompositionLogger) Debug(contents ...any)
- func (r *CompositionLogger) Debugf(format string, a ...any)
- func (r *CompositionLogger) Error(contents ...any) error
- func (r *CompositionLogger) Errorf(format string, a ...any) error
- func (r *CompositionLogger) Info(contents ...any)
- func (r *CompositionLogger) Infof(format string, a ...any)
- func (r *CompositionLogger) Log(logLevel eumLogLevel.Enum, content string, component string, newLine bool)
- func (r *CompositionLogger) Trace(contents ...any)
- func (r *CompositionLogger) Tracef(format string, a ...any)
- func (r *CompositionLogger) Warning(contents ...any)
- func (r *CompositionLogger) Warningf(format string, a ...any)
- type Config
- type ConsoleProvider
- type DefaultLoggerFactory
- type FileProvider
- type FopsProvider
- type IFormatter
- type ILoggerFactory
- type ILoggerPersistent
- type ILoggerProvider
- type JsonFormatter
- type LogData
- type TextFormatter
- type UploadRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var Colors = []brush{
newBrush("1;32"),
newBrush("1;36"),
newBrush("1;34"),
newBrush("1;33"),
newBrush("1;31"),
newBrush("1;35"),
newBrush("1;37"),
newBrush("1;44"),
newBrush("4"),
}
View Source
var LogBuffer = make(chan string, 1000)
LogBuffer 日志缓冲区
Functions ¶
func CloseBuffer ¶ added in v0.14.0
func CloseBuffer()
func ComponentInfof ¶
ComponentInfof 组件日志
func LoadLogBuffer ¶ added in v0.8.0
LoadLogBuffer 从日志缓冲区读取日志并打印
func ReplaceBlue ¶ added in v0.9.0
ReplaceBlue 转为蓝色字体
func ReplaceBlues ¶ added in v0.9.0
ReplaceBlues 转为蓝色字体
func ReplaceGreen ¶ added in v0.9.0
ReplaceGreen 转为绿色字体
func ReplaceGreens ¶ added in v0.9.0
ReplaceGreens 转为绿色字体
func ReplaceRed ¶ added in v0.9.0
ReplaceRed 转为红色字体
func ReplaceReds ¶ added in v0.9.0
ReplaceReds 转为红色字体
func ReplaceYellow ¶ added in v0.9.0
ReplaceYellow 转为黄色字体
func ReplaceYellows ¶ added in v0.9.0
ReplaceYellows 转为黄色字体
Types ¶
type CompositionLogger ¶ added in v0.8.0
type CompositionLogger struct {
// contains filtered or unexported fields
}
CompositionLogger 根据已添加的Provider,创建组合模式的Logger(壳)
func (*CompositionLogger) Critical ¶ added in v0.8.0
func (r *CompositionLogger) Critical(contents ...any)
func (*CompositionLogger) Criticalf ¶ added in v0.8.0
func (r *CompositionLogger) Criticalf(format string, a ...any)
func (*CompositionLogger) Debug ¶ added in v0.8.0
func (r *CompositionLogger) Debug(contents ...any)
func (*CompositionLogger) Debugf ¶ added in v0.8.0
func (r *CompositionLogger) Debugf(format string, a ...any)
func (*CompositionLogger) Error ¶ added in v0.8.0
func (r *CompositionLogger) Error(contents ...any) error
func (*CompositionLogger) Errorf ¶ added in v0.8.0
func (r *CompositionLogger) Errorf(format string, a ...any) error
func (*CompositionLogger) Info ¶ added in v0.8.0
func (r *CompositionLogger) Info(contents ...any)
func (*CompositionLogger) Infof ¶ added in v0.8.0
func (r *CompositionLogger) Infof(format string, a ...any)
func (*CompositionLogger) Log ¶ added in v0.8.0
func (r *CompositionLogger) Log(logLevel eumLogLevel.Enum, content string, component string, newLine bool)
func (*CompositionLogger) Trace ¶ added in v0.8.0
func (r *CompositionLogger) Trace(contents ...any)
func (*CompositionLogger) Tracef ¶ added in v0.8.0
func (r *CompositionLogger) Tracef(format string, a ...any)
func (*CompositionLogger) Warning ¶ added in v0.8.0
func (r *CompositionLogger) Warning(contents ...any)
func (*CompositionLogger) Warningf ¶ added in v0.8.0
func (r *CompositionLogger) Warningf(format string, a ...any)
type Config ¶ added in v0.6.0
type Config struct { Component componentConfig Default levelFormat Console levelFormat // 输出到控制台 File fileConfig // 写到文件 Fops levelFormat // 上传到FOPS }
type ConsoleProvider ¶ added in v0.8.0
type ConsoleProvider struct { }
ConsoleProvider 控制台打印
func (*ConsoleProvider) CreateLogger ¶ added in v0.8.0
func (r *ConsoleProvider) CreateLogger(categoryName string, formatter IFormatter, logLevel eumLogLevel.Enum) ILoggerPersistent
type DefaultLoggerFactory ¶ added in v0.8.0
type DefaultLoggerFactory struct {
// contains filtered or unexported fields
}
DefaultLoggerFactory 默认的日志创建工厂(不需要应用去实现)
func (*DefaultLoggerFactory) AddProvider ¶ added in v0.8.0
func (r *DefaultLoggerFactory) AddProvider(provider ILoggerProvider)
func (*DefaultLoggerFactory) AddProviderFormatter ¶ added in v0.8.0
func (r *DefaultLoggerFactory) AddProviderFormatter(provider ILoggerProvider, formatter IFormatter, logLevel eumLogLevel.Enum)
func (*DefaultLoggerFactory) CreateLogger ¶ added in v0.8.0
func (r *DefaultLoggerFactory) CreateLogger(categoryName string) core.ILog
type FileProvider ¶ added in v0.8.0
type FileProvider struct {
// contains filtered or unexported fields
}
FileProvider 控制台打印
func (*FileProvider) CreateLogger ¶ added in v0.8.0
func (r *FileProvider) CreateLogger(categoryName string, formatter IFormatter, logLevel eumLogLevel.Enum) ILoggerPersistent
type FopsProvider ¶ added in v0.12.0
type FopsProvider struct { }
FopsProvider 上传到FOPS
func (*FopsProvider) CreateLogger ¶ added in v0.12.0
func (r *FopsProvider) CreateLogger(categoryName string, formatter IFormatter, logLevel eumLogLevel.Enum) ILoggerPersistent
type IFormatter ¶ added in v0.8.0
IFormatter 日志格式
type ILoggerFactory ¶ added in v0.8.0
type ILoggerFactory interface { // AddProvider 添加多个日志写入提供者(应用初始化时调用) AddProvider(provider ILoggerProvider) // CreateLogger 根据已添加的Provider,创建组合模式的Logger(壳) CreateLogger(categoryName string) core.ILog }
type ILoggerPersistent ¶ added in v0.8.0
type ILoggerPersistent interface { // IsEnabled 根据日志等级确定是否需要记录 IsEnabled(logLevel eumLogLevel.Enum) bool // Log 日志记录 Log(LogLevel eumLogLevel.Enum, log *LogData, exception error) }
ILoggerPersistent 实际的日志记录器
type ILoggerProvider ¶ added in v0.8.0
type ILoggerProvider interface { // CreateLogger 创建对应的Logger对象,创建Logger CreateLogger(categoryName string, formatter IFormatter, logLevel eumLogLevel.Enum) ILoggerPersistent }
type JsonFormatter ¶ added in v0.8.0
type JsonFormatter struct { }
JsonFormatter json格式输出
func (JsonFormatter) Formatter ¶ added in v0.8.0
func (r JsonFormatter) Formatter(log *LogData) string
type LogData ¶ added in v0.12.0
type LogData struct { CreateAt dateTime.DateTime LogLevel eumLogLevel.Enum Component string // 组件名称 Content string // 上传到FOPS时使用 TraceId string // 上下文ID AppId string // 应用ID AppName string // 应用名称 AppIp string // 应用IP LogId string // 主键ID // contains filtered or unexported fields }
LogData 日志结构
type TextFormatter ¶ added in v0.8.0
type TextFormatter struct {
// contains filtered or unexported fields
}
TextFormatter 文本格式输出
func (TextFormatter) Formatter ¶ added in v0.8.0
func (r TextFormatter) Formatter(log *LogData) string
type UploadRequest ¶ added in v0.12.0
type UploadRequest struct {
List []*LogData
}
Click to show internal directories.
Click to hide internal directories.