Categorygithub.com/go-logfmt/logfmt
modulepackage
0.6.0
Repository: https://github.com/go-logfmt/logfmt.git
Documentation: pkg.go.dev

# README

logfmt

Go Reference Go Report Card Github Actions Coverage Status

Package logfmt implements utilities to marshal and unmarshal data in the logfmt format. It provides an API similar to encoding/json and encoding/xml.

The logfmt format was first documented by Brandur Leach in this article. The format has not been formally standardized. The most authoritative public specification to date has been the documentation of a Go Language package written by Blake Mizerany and Keith Rarick.

Goals

This project attempts to conform as closely as possible to the prior art, while also removing ambiguity where necessary to provide well behaved encoder and decoder implementations.

Non-goals

This project does not attempt to formally standardize the logfmt format. In the event that logfmt is standardized this project would take conforming to the standard as a goal.

Versioning

This project publishes releases according to the Go language guidelines for developing and publishing modules.

# Functions

MarshalKeyvals returns the logfmt encoding of keyvals, a variadic sequence of alternating keys and values.
NewDecoder returns a new decoder that reads from r.
NewDecoderSize returns a new decoder that reads from r.
NewEncoder returns a new encoder that writes to w.

# Variables

ErrInvalidKey is returned by Marshal functions and Encoder methods if, after dropping invalid runes, a key is empty.
ErrNilKey is returned by Marshal functions and Encoder methods if a key is a nil interface or pointer value.
ErrUnsupportedKeyType is returned by Encoder methods if a key has an unsupported type.
ErrUnsupportedValueType is returned by Encoder methods if a value has an unsupported type.

# Structs

A Decoder reads and decodes logfmt records from an input stream.
An Encoder writes logfmt data to an output stream.
MarshalerError represents an error encountered while marshaling a value.
A SyntaxError represents a syntax error in the logfmt input stream.