Help us shape the future of Go! Take the 2026 Go Developer Survey

bulog

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: MIT Imports: 6 Imported by: 0

README

bulog

Build Status codecov GoDoc Go Report Card

An alternative output destination for the standard library log package

Usage

When your application use default log package.

log.Println("hello world!")

// 2018/04/04 11:07:36 hello world!

You can enhance it a bit using bulog.Standard:

l := bulog.Standard(os.Stderr)
l.Println("hello world!")

// {"@timestamp":"2018-10-22T21:02:43+07:00","message":"hello world!"}

You can embed log level within the message:

l := bulog.Standard(os.Stderr)
l.Println("[INFO] hello world!")

// {"level":"info","@timestamp":"2018-10-22T21:04:27+07:00","message":"hello world!"}

If you prefer writing log message using logfmt format, bulog provides the support via bulog.Logfmt:

l := bulog.Logfmt(os.Stdout)
l.Println(`level="info" code=200 msg="hello world!"`)

// {"level":"info","code":200,"@timestamp":"2018-10-22T21:07:45+07:00","message":"hello world!"}

That's it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logfmt

func Logfmt(out io.Writer) *log.Logger

func LogfmtZero added in v1.1.0

func LogfmtZero(logger zerolog.Logger) *log.Logger

func Standard

func Standard(out io.Writer) *log.Logger

func StandardZero added in v1.1.0

func StandardZero(logger zerolog.Logger) *log.Logger

Types

This section is empty.

Jump to

Keyboard shortcuts

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