Skip to content

golage/log

Repository files navigation

Golage log handling https://github.com/golage/log https://github.com/golage/log https://github.com/golage/log

Simple and useful log handling package in Golang

Installation

Get from Github:

go get github.com/golage/log

How to use

Import into your code:

import "github.com/golage/log"

Set output writer:

log.SetOutput(w)

Set minimum log level (default: LevelInfo):

log.SetLevel(log.LevelDebug)

Set log formatter (default: TextFormatter):

log.SetFormatter(log.NewTextFormatter)
log.SetFormatter(log.NewJSONFormatter)
log.SetFormatter(log.NewYAMLFormatter)

Set constants data in all logs:

log.SetConstant("key", "value")

Add data to log:

log.With(err)
log.Value("key", "value")

Write log:

log.Debug("message")
log.Info("message")
log.Warning("message")
log.Error("message")
log.Fatal("message")

For more see example