log

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: GPL-3.0, LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLogfmtInt64

func FormatLogfmtInt64(n int64) string

FormatLogfmtInt64 formats n with thousand separators.

func FormatLogfmtUint64

func FormatLogfmtUint64(n uint64) string

FormatLogfmtUint64 formats n with thousand separators.

func PrintOrigins

func PrintOrigins(print bool)

PrintOrigins sets or unsets log location (file:line) printing for terminal format output.

func SubnetEVMJSONFormat

func SubnetEVMJSONFormat(alias string) log.Format

func SubnetEVMTermFormat

func SubnetEVMTermFormat(alias string) log.Format

Types

type Format

type Format interface {
	Format(r *log.Record) []byte
}

func FormatFunc

func FormatFunc(f func(*log.Record) []byte) Format

FormatFunc returns a new Format object which uses the given function to perform log.Record formatting.

func JSONFormat

func JSONFormat() Format

JSONFormat formats log log.Records as JSON objects separated by newlines. It is the equivalent of JSONFormatEx(false, true).

func JSONFormatEx

func JSONFormatEx(pretty, lineSeparated bool) Format

JSONFormatEx formats log log.Records as JSON objects. If pretty is true, log.Records will be pretty-printed. If lineSeparated is true, log.Records will be logged with a new line between each log.Record.

func JSONFormatOrderedEx

func JSONFormatOrderedEx(pretty, lineSeparated bool) Format

JSONFormatOrderedEx formats log log.Records as JSON arrays. If pretty is true, log.Records will be pretty-printed. If lineSeparated is true, log.Records will be logged with a new line between each log.Record.

func LogfmtFormat

func LogfmtFormat() Format

LogfmtFormat prints log.Records in logfmt format, an easy machine-parseable but human-readable format for key/value pairs.

For more details see: http://godoc.org/github.com/kr/logfmt

func TerminalFormat

func TerminalFormat(usecolor bool) Format

TerminalFormat formats log log.Records optimized for human readability on a terminal with color-coded level output and terser human friendly timestamp. This format should only be used for interactive programs or while developing.

[LEVEL] [TIME] MESSAGE key=value key=value ...

Example:

[DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002

type TerminalStringer

type TerminalStringer interface {
	TerminalString() string
}

TerminalStringer is an analogous interface to the stdlib stringer, allowing own types to have custom shortened serialization formats when printed to the screen.

Jump to

Keyboard shortcuts

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