Skip to content

msales/logged

Repository files navigation

logged

Go Report Card Build Status Coverage Status GoDoc GitHub release GitHub license

A fast logger for Go.

Overview

Install with:

go get github.com/msales/logged

Examples

// Composable handlers
h := logged.LevelFilterHandler(
    logged.Info,
    logged.StreamHandler(os.Stdout, logged.LogfmtFormat()),
)

// The logger can have an initial context
l := logged.New(h, "env", "prod")

// All messages can have a context
l.Warn("connection error", "redis", conn.Name(), "timeout", conn.Timeout())

Will log the message

lvl=warn msg="connection error" redis=dsn_1 timeout=0.500

License

MIT-License. As is. No warranties whatsoever. Mileage may vary. Batteries not included.