Documentation
¶
Overview ¶
Package format provides a logrus formatter that formats log entries in a structured way.
Index ¶
Constants ¶
View Source
const ( PrefixKeyName = "prefix" TFBinaryKeyName = "tfBinary" )
View Source
const ( FieldKeyMsg = "msg" FieldKeyLevel = "level" FieldKeyTime = "time" FieldKeyLogrusError = "logrus_error" FieldKeyFunc = "func" FieldKeyFile = "file" )
Default key names for the default fields.
Variables ¶
This section is empty.
Functions ¶
func NewPrefixStyle ¶
func NewPrefixStyle() *prefixStyle
Types ¶
type ColorScheme ¶
type ColorScheme map[ColorStyleName]ColorStyle
func (ColorScheme) Compile ¶
func (scheme ColorScheme) Compile() compiledColorScheme
type ColorStyle ¶
type ColorStyle string
func (ColorStyle) ColorFunc ¶
func (style ColorStyle) ColorFunc() ColorFunc
type ColorStyleName ¶
type ColorStyleName byte
const ( None ColorStyleName = iota InfoLevelStyle WarnLevelStyle ErrorLevelStyle FatalLevelStyle PanicLevelStyle DebugLevelStyle TraceLevelStyle TFBinaryStyle TimestampStyle )
type FieldMap ¶
type FieldMap map[fieldKey]string
FieldMap allows customization of the key names for default fields.
type Formatter ¶
type Formatter struct {
// Disable formatted layout
DisableLogFormatting bool
// Force disabling colors. For a TTY colors are enabled by default.
DisableColors bool
// Disable the conversion of the log levels to uppercase
DisableUppercase bool
// Timestamp format to use for display when a full timestamp is printed.
TimestampFormat string
// The fields are sorted by default for a consistent output.
DisableSorting bool
// Wrap empty fields in quotes if true.
QuoteEmptyFields bool
// Can be set to the override the default quoting character " with something else. For example: ', or `.
QuoteCharacter string
// PrefixStyle is used to assign different styles (colors) to each prefix.
PrefixStyle PrefixStyle
// contains filtered or unexported fields
}
func NewFormatter ¶
func NewFormatter() *Formatter
NewFormatter returns a new Formatter instance with default values.
func (*Formatter) SetColorScheme ¶
func (formatter *Formatter) SetColorScheme(colorScheme *ColorScheme)
type JSONFormatter ¶
type JSONFormatter struct {
// TimestampFormat sets the format used for marshaling timestamps.
TimestampFormat string
// DisableTimestamp allows disabling automatic timestamps in output.
DisableTimestamp bool
// DisableHTMLEscape allows disabling html escaping in output.
DisableHTMLEscape bool
// DataKey allows users to put all the log entry parameters into a nested dictionary at a given key.
DataKey string
// FieldMap allows users to customize the names of keys for default fields.
FieldMap FieldMap
// PrettyPrint will indent all json logs.
PrettyPrint bool
}
JSONFormatter formats logs into parsable json.
type PrefixStyle ¶
type SilentFormatter ¶
type SilentFormatter struct{}
SilentFormatter disables logging by not outputting anything.
Click to show internal directories.
Click to hide internal directories.