encoder

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package encoder implements log encoders used to output logs in varying ways.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MessageKey     *string `json:"message_key,omitempty"`
	LevelKey       *string `json:"level_key,omitempty"`
	TimeKey        *string `json:"time_key,omitempty"`
	NameKey        *string `json:"name_key,omitempty"`
	CallerKey      *string `json:"caller_key,omitempty"`
	StacktraceKey  *string `json:"stacktrace_key,omitempty"`
	LineEnding     *string `json:"line_ending,omitempty"`
	TimeFormat     string  `json:"time_format,omitempty"`
	DurationFormat string  `json:"duration_format,omitempty"`
	LevelFormat    string  `json:"level_format,omitempty"`
	CallerFormat   string  `json:"caller_format,omitempty"`
}

Config represents the configuration for a log encoder.

func (*Config) ZapcoreEncoderConfig

func (c *Config) ZapcoreEncoderConfig() zapcore.EncoderConfig

ZapcoreEncoderConfig returns a zap encoder config, built from the Config values.

type Console

type Console struct {
	Config
	zapcore.Encoder `json:"-"`
}

Console is a log encoder for human-readable colored console output. This encoder is designed for development where only humans are reading the output.

func (*Console) Provision

func (e *Console) Provision() error

type Encoder

type Encoder interface {
	zapcore.Encoder
	Provision() error
}

Encoder is an interface for a log encoder.

type JSON

type JSON struct {
	Config
	zapcore.Encoder `json:"-"`
}

JSON is a log encoder for machine-readable JSON objects. Each line is output as a separate JSON object, essentially making the entire log output JSON-ND. This encoder is designed for production where logs are read and ingested by log aggregation systems.

func (*JSON) Provision

func (e *JSON) Provision() error

type Logfmt

type Logfmt struct {
	Config
	zapcore.Encoder `json:"-"`
}

Logfmt is a log encoder for machine and human-readable logs, it follows the logfmt "standard" first documented by [Brandur Leach](https://brandur.org/logfmt). This encoder is designed for both development and production where logs may need to be read by both humans and log aggregation systems, it's a middle ground between the Console and JSON log encoders. This is the default log encoder.

func (*Logfmt) Provision

func (e *Logfmt) Provision() error

Jump to

Keyboard shortcuts

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