loggingFormatter

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 6 Imported by: 0

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.

func (*Formatter) Format

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error)

Use: loggingFormatter.Formatter{} (Struct) |DESCRIPTION| Format building log message as standard text |ARGS|

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
	MessageNoQuote  bool   // If true, don't put the message field in quotes
}

JSONFormatter formats logs into parsable json

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(entry *logrus.Entry) ([]byte, error)

Use: loggingFormatter.JSONFormatter{} (Struct) |DESCRIPTION| Format renders a single log entry as JSON |ARGS| Prefix (string), Timezone (string), MessageNoQuote (bool)

Jump to

Keyboard shortcuts

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