format

package
v0.0.0-...-3cf0c3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogrusLogstashFormatter

func DefaultLogrusLogstashFormatter(fields logrus.Fields) logrus.Formatter

DefaultLogrusLogstashFormatter returns a default Logstash formatter: A JSON format with "@version" set to "1" (unless set differently in `fields`, "type" to "log" (unless set differently in `fields`), "@timestamp" to the log time and "message" to the log message.

Note: to set a different configuration use the `LogstashFormatter` structure.

func DefaultLogrusLokiFormatter

func DefaultLogrusLokiFormatter(fields logrus.Fields) logrus.Formatter

DefaultLogrusLokiFormatter returns a default loki formatter: A JSON format with "@version" set to "1" (unless set differently in `fields`, "type" to "log" (unless set differently in `fields`), "@timestamp" to the log time and "message" to the log message.

Note: to set a different configuration use the `LogrusLokiFormatter` structure.

Types

type LogrusLogstashFormatter

type LogrusLogstashFormatter struct {
	logrus.Formatter
	logrus.Fields
}

LogrusLogstashFormatter represents a Logstash format. It has logrus.Formatter which formats the entry and logrus.Fields which are added to the JSON message if not given in the entry data.

Note: use the `DefaultFormatter` function to set a default Logstash formatter.

func (*LogrusLogstashFormatter) Format

func (f *LogrusLogstashFormatter) Format(e *logrus.Entry) ([]byte, error)

Format formats an entry to a Logstash format according to the given Formatter and Fields.

Note: the given entry is copied and not changed during the formatting process.

type LogrusLokiFormatter

type LogrusLokiFormatter struct {
	logrus.Formatter
	logrus.Fields
}

LogrusLokiFormatter represents a loki format. It has logrus.Formatter which formats the entry and logrus.Fields which are added to the JSON message if not given in the entry data.

Note: use the `DefaultFormatter` function to set a default loki formatter.

func (*LogrusLokiFormatter) Format

func (f *LogrusLokiFormatter) Format(e *logrus.Entry) ([]byte, error)

Format formats an entry to a loki format according to the given Formatter and Fields.

Note: the given entry is copied and not changed during the formatting process.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL