Documentation
¶
Index ¶
Constants ¶
const LabelComponent = "component"
LabelComponent defines the special "component" field
const (
// RFC3339Milli is time.RFC3339 with milliseconds
RFC3339Milli = "2006-01-02T15:04:05.000Z07:00"
)
Variables ¶
var ( // JSONFormatter is the Datadog compatible logging format in JSON // Reassignment of this field only takes effect after it's reapplied (e.g. by logger.SetJSONFormat) JSONFormatter = &logrus.JSONFormatter{ FieldMap: logrus.FieldMap{ logrus.FieldKeyTime: "timestamp", logrus.FieldKeyLevel: "level", logrus.FieldKeyMsg: "message", }, TimestampFormat: RFC3339Milli, } // TextFormatter is the default text format // Reassignment of this field only takes effect after it's reapplied (e.g. by logger.SetTextFormat) TextFormatter = &logrus.TextFormatter{ TimestampFormat: RFC3339Milli, FullTimestamp: true, DisableColors: true, } )
var ( // RetryInterval is how long upstream waits after connection interruption before trying again. // Changes to the variable take effect immediately. RetryInterval = 10 * time.Second )
Functions ¶
func FormatFields ¶
FormatFields formats all but "component" fields into string, e.g. "name=Foo type=Bar status=..."
func IsTerminalWriter ¶
IsTerminalWriter checks whether the given writer is a terminal (suitable for color formatting)
Types ¶
type ConsoleLogFormatter ¶
type ConsoleLogFormatter struct { ForceColor bool // Force enable colored mode even for non-terminal log writer FallbackFormatter logrus.Formatter // Fallback formatter to use for non-terminal. If nil, use built-in fallback format (human readable, not for field parsing) // contains filtered or unexported fields }
ConsoleLogFormatter is colored output format for console / terminals It detects the type of output writers automatically and only enables if the type is terminal
func NewConsoleLogFormatter ¶
func NewConsoleLogFormatter(forceColor bool, fallbackFormatter logrus.Formatter) *ConsoleLogFormatter
NewConsoleLogFormatter creates a new ConsoleLogFormatter
type UpstreamTCPBufferedHook ¶
type UpstreamTCPBufferedHook struct {
// contains filtered or unexported fields
}
UpstreamTCPBufferedHook to forward logs to remote TCP upstream. Currently we're forwarding JSON formatted logs to Datadog agent. The hook buffers logs and send them in background - it requires logger.Exit() at app exit.
func NewUpstreamTCPBufferedHook ¶
func NewUpstreamTCPBufferedHook(endpoint string) *UpstreamTCPBufferedHook
NewUpstreamTCPBufferedHook creates a hook to be added to an instance of logger.
func (*UpstreamTCPBufferedHook) Fire ¶
func (hook *UpstreamTCPBufferedHook) Fire(entry *logrus.Entry) error
Fire is called to forward a logrus Entry / log record
func (*UpstreamTCPBufferedHook) Levels ¶
func (hook *UpstreamTCPBufferedHook) Levels() []logrus.Level
Levels defines the levels of logs to be sent to this hook
type UpstreamTCPUnbufferedHook ¶
type UpstreamTCPUnbufferedHook struct {
// contains filtered or unexported fields
}
UpstreamTCPUnbufferedHook to forward logs to localhost TCP upstream. Currently we're forwarding JSON formatted logs to Datadog agent. The hook writes logs immediately (blocking).
func NewUpstreamTCPUnbufferedHook ¶
func NewUpstreamTCPUnbufferedHook(endpoint string) *UpstreamTCPUnbufferedHook
NewUpstreamTCPUnbufferedHook creates a hook to be added to an instance of logger.
func (*UpstreamTCPUnbufferedHook) Fire ¶
func (hook *UpstreamTCPUnbufferedHook) Fire(entry *logrus.Entry) error
Fire is called to forward a logrus Entry / log record
func (*UpstreamTCPUnbufferedHook) Levels ¶
func (hook *UpstreamTCPUnbufferedHook) Levels() []logrus.Level
Levels defines the levels of logs to be sent to this hook