Documentation
¶
Index ¶
- func Color(l level.LogLevel) string
- func SetLoggerName(name string)
- type BaseFormatter
- type BaseFormatterConfig
- func (c BaseFormatterConfig) WithEnableColor() BaseFormatterConfig
- func (c BaseFormatterConfig) WithEnableHostname() BaseFormatterConfig
- func (c BaseFormatterConfig) WithEnableIP() BaseFormatterConfig
- func (c BaseFormatterConfig) WithEnablePid() BaseFormatterConfig
- func (c BaseFormatterConfig) WithEnableTimestamp() BaseFormatterConfig
- func (c BaseFormatterConfig) WithShortLevel() BaseFormatterConfig
- func (c BaseFormatterConfig) WithTimeLayout(layout string) BaseFormatterConfig
- type IFormatter
- type JSONFormatter
- type JSONFormatterConfig
- type TextFormatter
- type TextFormatterConfig
- func (c *TextFormatterConfig) WithBaseFormatterConfig(baseCfg BaseFormatterConfig) *TextFormatterConfig
- func (c *TextFormatterConfig) WithEnableQuote() *TextFormatterConfig
- func (c *TextFormatterConfig) WithEnableQuoteEmptyFields() *TextFormatterConfig
- func (c *TextFormatterConfig) WithPatternStyle(pattern string) *TextFormatterConfig
- type TimeFormatter
- type XMLFormatter
- type XMLFormatterConfig
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.Record
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
}
func (BaseFormatterConfig) WithEnableColor ¶ added in v0.4.1
func (c BaseFormatterConfig) WithEnableColor() BaseFormatterConfig
func (BaseFormatterConfig) WithEnableHostname ¶ added in v0.4.1
func (c BaseFormatterConfig) WithEnableHostname() BaseFormatterConfig
func (BaseFormatterConfig) WithEnableIP ¶ added in v0.4.1
func (c BaseFormatterConfig) WithEnableIP() BaseFormatterConfig
func (BaseFormatterConfig) WithEnablePid ¶ added in v0.4.1
func (c BaseFormatterConfig) WithEnablePid() BaseFormatterConfig
func (BaseFormatterConfig) WithEnableTimestamp ¶ added in v0.4.1
func (c BaseFormatterConfig) WithEnableTimestamp() BaseFormatterConfig
func (BaseFormatterConfig) WithShortLevel ¶ added in v0.4.1
func (c BaseFormatterConfig) WithShortLevel() BaseFormatterConfig
func (BaseFormatterConfig) WithTimeLayout ¶ added in v0.4.1
func (c BaseFormatterConfig) WithTimeLayout(layout string) BaseFormatterConfig
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.
}
func (*JSONFormatterConfig) WithBaseFormatterConfig ¶ added in v0.4.1
func (c *JSONFormatterConfig) WithBaseFormatterConfig(baseCfg BaseFormatterConfig) *JSONFormatterConfig
func (*JSONFormatterConfig) WithDisableHTMLEscape ¶ added in v0.4.1
func (c *JSONFormatterConfig) WithDisableHTMLEscape() *JSONFormatterConfig
func (*JSONFormatterConfig) WithPrettyPrint ¶ added in v0.4.1
func (c *JSONFormatterConfig) WithPrettyPrint() *JSONFormatterConfig
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.Record)
func (*TextFormatter) ColorRenderV2 ¶
func (f *TextFormatter) ColorRenderV2(b *bytes.Buffer, m *message.Record)
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.
}
func (*TextFormatterConfig) WithBaseFormatterConfig ¶ added in v0.4.1
func (c *TextFormatterConfig) WithBaseFormatterConfig(baseCfg BaseFormatterConfig) *TextFormatterConfig
func (*TextFormatterConfig) WithEnableQuote ¶ added in v0.4.1
func (c *TextFormatterConfig) WithEnableQuote() *TextFormatterConfig
func (*TextFormatterConfig) WithEnableQuoteEmptyFields ¶ added in v0.4.1
func (c *TextFormatterConfig) WithEnableQuoteEmptyFields() *TextFormatterConfig
func (*TextFormatterConfig) WithPatternStyle ¶ added in v0.4.1
func (c *TextFormatterConfig) WithPatternStyle(pattern string) *TextFormatterConfig
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.
}
func (*XMLFormatterConfig) WithBaseFormatterConfig ¶ added in v0.4.1
func (c *XMLFormatterConfig) WithBaseFormatterConfig(baseCfg BaseFormatterConfig) *XMLFormatterConfig
func (*XMLFormatterConfig) WithPrettyPrint ¶ added in v0.4.1
func (c *XMLFormatterConfig) WithPrettyPrint() *XMLFormatterConfig
Click to show internal directories.
Click to hide internal directories.