Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLoggerName ¶ added in v0.4.0
func SetLoggerName(name string)
Types ¶
type BaseFormatter ¶ added in v0.4.0
type BaseFormatter struct {
*TimeFormatter
// contains filtered or unexported fields
}
func NewBaseFormatter ¶ added in v0.4.0
func NewBaseFormatter(cfg BaseFormatterConfig) *BaseFormatter
func (*BaseFormatter) ConvertToMessage ¶ added in v0.4.0
func (b *BaseFormatter) ConvertToMessage(e *message.Entry) *message.Message
type BaseFormatterConfig ¶ added in v0.4.0
type BaseFormatterConfig struct {
// time layout string, for example: "2006-01-02 15:04:05.000"
TimeLayout string
// enable color rendering
EnableColor bool
// short level string, for example: "Err" instead of "Error"
ShortLevel bool
// record pid in message
EnablePid bool
// record ip in message
EnableIP bool
// record hostname in message
EnableHostname bool
// record timestamp(int64 ms) in message
EnableTimestamp bool
}
type JSONFormatter ¶
type JSONFormatter struct {
*BaseFormatter
// contains filtered or unexported fields
}
func NewJSONFormatter ¶
func NewJSONFormatter(cfg JSONFormatterConfig) *JSONFormatter
type JSONFormatterConfig ¶ added in v0.4.0
type JSONFormatterConfig struct {
BaseFormatterConfig
DisableHTMLEscape bool // [json formatter] allows disabling html escaping in output.
PrettyPrint bool // [json|xml formatter] will indent all json logs.
}
type TextFormatter ¶
type TextFormatter struct {
*BaseFormatter
EnableQuote bool
EnableQuoteEmptyFields bool
DisableColors bool
// contains filtered or unexported fields
}
TextFormatter formats logs into text
func NewTextFormatter ¶
func NewTextFormatter(cfg TextFormatterConfig) *TextFormatter
func (*TextFormatter) ColorRender ¶
func (f *TextFormatter) ColorRender(b *bytes.Buffer, m *message.Message)
func (*TextFormatter) ColorRenderV2 ¶
func (f *TextFormatter) ColorRenderV2(b *bytes.Buffer, m *message.Message)
type TextFormatterConfig ¶ added in v0.4.0
type TextFormatterConfig struct {
BaseFormatterConfig
PatternStyle string // [text formatter] style template for formatting the data, which determines the order of the fields and the presentation style.
EnableQuote bool // [text formatter] keep the string literal, while escaping safely if necessary.
EnableQuoteEmptyFields bool // [text formatter] when the value of field is empty, keep the string literal.
}
type TimeFormatter ¶ added in v0.4.0
type TimeFormatter struct {
SecondLayout string
// contains filtered or unexported fields
}
func NewTimeFormatter ¶ added in v0.4.0
func NewTimeFormatter(layout string) *TimeFormatter
func (*TimeFormatter) FormatDateTime ¶ added in v0.4.0
func (tf *TimeFormatter) FormatDateTime(t time.Time) string
FormatDateTime Influenced by parallelism, small probability took the old value. Because it is logging, we don't make it so strict
func (*TimeFormatter) SetTimeDecimalFormat ¶ added in v0.4.0
func (tf *TimeFormatter) SetTimeDecimalFormat(decimal int)
type XMLFormatter ¶
type XMLFormatter struct {
*BaseFormatter
PrettyPrint bool
}
func NewXMLFormatter ¶
func NewXMLFormatter(cfg XMLFormatterConfig) *XMLFormatter
type XMLFormatterConfig ¶ added in v0.4.0
type XMLFormatterConfig struct {
BaseFormatterConfig
PrettyPrint bool // [json|xml formatter] will indent all json logs.
}
Click to show internal directories.
Click to hide internal directories.