logex

package
v0.0.0-...-cdd0c7f Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

See my blog post about fixing Go´s logging mess.

Documentation

Overview

"Logging extensions" - https://joonas.fi/2018/12/04/an-idea-to-fix-gos-logging-mess/

Index

Constants

This section is empty.

Variables

View Source
var Discard = log.New(ioutil.Discard, "", 0)

a logger that discards its output

Functions

func Filter

func Filter(filter *regexp.Regexp, matches *log.Logger) *log.Logger

pipes Logger's output (io.Writer) into another Logger, but only if entry matches regex

func NonNil

func NonNil(ref *log.Logger) *log.Logger

helper for libraries in getting an alwas non-nil logger. if a logger given to you was nil, you get a Discard logger back, which you can call safely - it doesn't write anywhere

func OutputToAnotherLog

func OutputToAnotherLog(another *log.Logger) io.Writer

pipes Logger's output (io.Writer) into another Logger

func Prefix

func Prefix(prefix string, parent *log.Logger) *log.Logger

Prefix() creates a new Logger whose output is piped to parent logger with a prefix

func RedirectGlobalStdLog

func RedirectGlobalStdLog(to *log.Logger)

func StandardLogger

func StandardLogger() *log.Logger

centralized place for creating "standard" stderr logger in a way that supports suppressing log timestamps if a mechanism around it (Docker/systemd) would add one anyway

func StandardLoggerTo

func StandardLoggerTo(sink io.Writer) *log.Logger

same as StandardLogger() but with explicit sink

Types

type Leveled

type Leveled struct {
	Debug *log.Logger
	Info  *log.Logger
	Error *log.Logger
}

func Levels

func Levels(parent *log.Logger) *Leveled

Jump to

Keyboard shortcuts

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