Categorygithub.com/mattn/log
modulepackage
1.2.0
Repository: https://github.com/mattn/log.git
Documentation: pkg.go.dev

# README

GitHub release GoDoc Build Status Go Report Card License

Logging framework for Go

This is a logging framework mainly for our Go products.

Be warned that this is a framework rather than a library. Most features cannot be configured.

Features

  • Light-weight.

    Hard-coded maximum log buffer size and 1-pass formatters help cybozu/log be memory- and CPU- efficient.

  • Built-in logfmt and JSON Lines formatters.

    By default, logs are formatted in syslog-like plain text. logfmt and JSON Lines formatters can be used alternatively.

  • Automatic redirect for Go standard logs.

    The framework automatically redirects Go standard logs to itself.

  • Reopen handler.

    The framework comes with a handy writer that reopens the log file upon signal reception. Useful for work with log rotating programs.

    Only for non-Windows systems.

Usage

Read the documentation.

Log structure

Read SPEC.md.

License

MIT

# Functions

Critical outputs a critical log using the default logger.
Debug outputs a debug log using the default logger.
DefaultLogger returns the pointer to the default logger.
Enabled does the same for Logger.Enabled() for the default logger.
Error outputs an error log using the default logger.
ErrorExit outputs an error log using the default logger, then exit.
Info outputs an informational log using the default logger.
IsValidKey returns true if given key is valid for extra fields.
LevelName returns the name for the defined threshold.
NewFileReopener returns io.Writer that will reopen the named file when signals are received.
NewLogger constructs a new Logger struct.
NewReopenWriter constructs a io.Writer that reopens inner io.WriteCloser when signals are received.
ReservedKey returns true if k is a field name reserved for log formatters.
Warn outputs a warning log using the default logger.

# Constants

EnvLogLevel ks the environment variable name to configure the default logger's log level at program startup.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Standard log field names.
Severities a.k.a log levels.
Severities a.k.a log levels.
Severities a.k.a log levels.
Severities a.k.a log levels.
Severities a.k.a log levels.
RFC3339Micro is for time.Time.Format().

# Variables

ErrInvalidData is returned when fields contain invalid data.
ErrInvalidKey is returned when fields contain invalid key.
ErrTooLarge is returned for too large log.

# Structs

JSONFormat implements Formatter for JSON Lines.
Logfmt implements Formatter for logfmt format.
Logger is a collection of properties how to output logs.
MsgPack implements Formatter for msgpack format.
PlainFormat implements Formatter to generate plain log messages.

# Interfaces

Formatter is the interface for log formatters.
Opener returns a new io.WriteCloser.