Documentation
¶
Overview ¶
This package is used provide a standardized format for loggers using the sirupsen/logrus package.
Index ¶
Constants ¶
View Source
const ( JSONLogFormat = "{\"id\":\"%id%\",\"timestamp\":\"%time%\",\"level\":\"%lvl%\",\"context\":\"%context%\",\"message\":\"%msg%\"}\n" JSONLogMessageNoQuote = "{\"id\":\"%id%\",\"timestamp\":\"%time%\",\"level\":\"%lvl%\",\"context\":\"%context%\",\"message\":%msg%}\n" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
type Formatter struct {
TimestampFormat string // Format string for timestamp
LogFormat string // Format string for log output
}
Formatter implements logrus.Formatter interface.
type JSONFormatter ¶
type JSONFormatter struct {
TimestampFormat string // Format string for timestamp
Prefix string // Prefix to write at the beginning of each line
Timezone string // Timezone to use for timestamps
LogFormat string // Format string for log output
CorrelationID string // Correlation ID to include in logs
MessageNoQuote bool // If true, don't put the message field in quotes
// contains filtered or unexported fields
}
JSONFormatter formats logs into parsable json
func NewJSONFormatter ¶ added in v0.0.23
func NewJSONFormatter(timestampFormat string, correlationID string, prefix string, timezone string, messageNoQuote bool) *JSONFormatter
NewJSONFormatter creates a new JSONFormatter
type LogEntry ¶ added in v0.0.23
type LogEntry struct {
ID string `json:"id"`
Time string `json:"time"`
Level string `json:"level"`
CorrelationID string `json:"correlation,omitempty"`
Context string `json:"context"`
Message string `json:"message"`
Data logrus.Fields `json:"data,omitempty"`
}
LogEntry is the log entry structure for JSONFormatter
Click to show internal directories.
Click to hide internal directories.