Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(format string, v ...interface{})
- func DebugD(depth int, format string, v ...interface{})
- func DebugDv(depth int, v ...interface{})
- func Debugv(v ...interface{})
- func Error(format string, v ...interface{})
- func ErrorD(depth int, format string, v ...interface{})
- func ErrorDv(depth int, v ...interface{})
- func Errorv(v ...interface{})
- func Fatal(format string, v ...interface{})
- func FatalD(depth int, format string, v ...interface{})
- func FatalDv(depth int, v ...interface{})
- func Fatalv(v ...interface{})
- func Filter(filter func(msg *LogUnit) bool)
- func Info(format string, v ...interface{})
- func InfoD(depth int, format string, v ...interface{})
- func InfoDv(depth int, v ...interface{})
- func Infov(v ...interface{})
- func Init(conf *Config)
- func New(conf *Config) *logger
- func RegThreshold(name string, referValue int64, durationRate time.Duration, fmtContent string)
- func Term()
- func Threshold(name string) *threshold
- func Trace(format string, v ...interface{})
- func TraceD(depth int, format string, v ...interface{})
- func TraceDv(depth int, v ...interface{})
- func Tracev(v ...interface{})
- func UseGelf(conf *GraylogConf)
- func Warn(format string, v ...interface{})
- func WarnD(depth int, format string, v ...interface{})
- func WarnDv(depth int, v ...interface{})
- func Warnv(v ...interface{})
- type CompressType
- type Config
- type ELogLevel
- type ELogMode
- type ELoggerStatus
- type GraylogConf
- type ILoger
- type LogFields
- func (l *LogFields) Clone() ILoger
- func (l *LogFields) Debug(format string, v ...interface{})
- func (l *LogFields) DebugD(depth int, format string, v ...interface{})
- func (l *LogFields) DebugDv(depth int, v ...interface{})
- func (l *LogFields) Debugv(v ...interface{})
- func (l *LogFields) Error(format string, v ...interface{})
- func (l *LogFields) ErrorD(depth int, format string, v ...interface{})
- func (l *LogFields) ErrorDv(depth int, v ...interface{})
- func (l *LogFields) Errorv(v ...interface{})
- func (l *LogFields) Fatal(format string, v ...interface{})
- func (l *LogFields) FatalD(depth int, format string, v ...interface{})
- func (l *LogFields) FatalDv(depth int, v ...interface{})
- func (l *LogFields) Fatalv(v ...interface{})
- func (l *LogFields) Field(field string, val interface{}) ILoger
- func (l *LogFields) Info(format string, v ...interface{})
- func (l *LogFields) InfoD(depth int, format string, v ...interface{})
- func (l *LogFields) InfoDv(depth int, v ...interface{})
- func (l *LogFields) Infov(v ...interface{})
- func (l *LogFields) Init(field string, val interface{}) ILoger
- func (l *LogFields) Trace(format string, v ...interface{})
- func (l *LogFields) TraceD(depth int, format string, v ...interface{})
- func (l *LogFields) TraceDv(depth int, v ...interface{})
- func (l *LogFields) Tracev(v ...interface{})
- func (l *LogFields) Warn(format string, v ...interface{})
- func (l *LogFields) WarnD(depth int, format string, v ...interface{})
- func (l *LogFields) WarnDv(depth int, v ...interface{})
- func (l *LogFields) Warnv(v ...interface{})
- type LogUnit
- type Message
- type Writer
Constants ¶
View Source
const ( C_LOG_MODE = ELM_Std // 默认日志输出模式 C_LOG_LEVEL = ELL_Debug // 默认日志过滤等级 C_LOG_FILE_SUFFIX = "log" // 默认日志文件后缀 C_LOG_ROTATE_NUM = 3 // 默认日志文件轮换数量 C_LOG_ROTATE_SIZE = 20 * 1024 * 1024 // 默认日志文件轮换size C_LOG_CSIZE = 2048 // 默认日志消息ChanSize C_TH_CHAN_OVERLOAD = "Threshold:%s" // 消息积压阀值名称 C_TH_CHAN_OVERLOAD_VALUE = C_LOG_CSIZE * 0.8 // 消息积压阀值(过大时告警) )
View Source
const (
ChunkSize = 1420
)
Used to control GELF chunking. Should be less than (MTU - len(UDP header)).
TODO: generate dynamically using Path MTU Discovery?
Variables ¶
View Source
var ( LOG_MSG_LV_PREFIXS = [ELL_Max]string{"[TRC]", "[DBG]", "[INF]", "[WRN]", "[ERR]", "[FAL]"} // fail LOG_MSG_COLORS = [ELL_Max]int{97, 94, 92, 93, 91, 95} // colors )
Functions ¶
func RegThreshold ¶
Types ¶
type CompressType ¶
type CompressType int
What compression type the writer should use when sending messages to the graylog server
const ( CompressGzip CompressType = iota CompressZlib CompressNone )
type Config ¶
type Config struct {
Level ELogLevel `json:"lv"` // 日志等级[ELL_Debug]
OutMode ELogMode `json:"mode"` // 日志输出模式
DirName string `json:"dir"` // 输出目录[默认在程序所在目录]
FileName string `json:"fileName"` // 日志文件主名[程序本身名]
FileSuffix string `json:"fileSuffix"` // 日志文件后缀[log]
RotateMax int `json:"rotateMax"` // 日志文件轮换数量[3]
RotateSize int `json:"rotateSize"` // 日志文件轮换大小[20m]
}
日志配置
type ELoggerStatus ¶
type ELoggerStatus int //
日志运行状态
const ( ELS_Initing ELoggerStatus = iota ELS_Running ELS_Exiting ELS_Stopped ELS_Max )
func (ELoggerStatus) String ¶
func (e ELoggerStatus) String() string
type GraylogConf ¶
type GraylogConf struct {
Address string `json:"addr"` // graylog地址(ip:port)
GelfIntercept bool `json:"intercept"` // graylog是否拦截标准输出
Service string `json:"service"` // app.server.env
WithFull bool `json:"withFull"` // false
}
灰日志配置
type ILoger ¶
type ILoger interface {
// 添加扩展字段
Field(field string, val interface{}) ILoger
// 克隆ILoger对象
Clone() ILoger
// TRACE
Trace(format string, v ...interface{})
Tracev(v ...interface{})
TraceD(depth int, format string, v ...interface{})
TraceDv(depth int, v ...interface{})
// DEBUG
Debug(format string, v ...interface{})
Debugv(v ...interface{})
DebugD(depth int, format string, v ...interface{})
DebugDv(depth int, v ...interface{})
// INFO
Info(format string, v ...interface{})
Infov(v ...interface{})
InfoD(depth int, format string, v ...interface{})
InfoDv(depth int, v ...interface{})
// WARN
Warn(format string, v ...interface{})
Warnv(v ...interface{})
WarnD(depth int, format string, v ...interface{})
WarnDv(depth int, v ...interface{})
// ERROR
Error(format string, v ...interface{})
Errorv(v ...interface{})
ErrorD(depth int, format string, v ...interface{})
ErrorDv(depth int, v ...interface{})
// FATAL
Fatal(format string, v ...interface{})
Fatalv(v ...interface{})
FatalD(depth int, format string, v ...interface{})
FatalDv(depth int, v ...interface{})
}
ILoger interface
type Message ¶
type Message struct {
Version string `json:"version"` // internal
Host string `json:"host"` // internal
Short string `json:"short_message"` // internal(message field)
Full string `json:"full_message,omitempty"` // invalid
TimeUnix float64 `json:"timestamp"` // 时间戳
CreateOrder int64 `json:"message_order"` // 消息生产顺序
Level int32 `json:"level"` // 日志等级
LevelName string `json:"level_name,omitempty"` // 日志等级名称
Facility string `json:"tag,omitempty"` // 服务名称
MsgSize string `json:"message_size,omitempty"` // 消息大小
Extra map[string]interface{} `json:"-"`
RawExtra json.RawMessage `json:"-"` // 扩展用
}
Message represents the contents of the GELF message. It is gzipped before sending.
type Writer ¶
type Writer struct {
Facility string // defaults to current process name
CompressionLevel int // one of the consts from compress/flate
CompressionType CompressType
IncPerSecond int
// contains filtered or unexported fields
}
Writer implements io.Writer and is used to send both discrete messages to a graylog2 server, or data from a stream-oriented interface (like the functions in log).
Click to show internal directories.
Click to hide internal directories.