Simple logger inspired by bwmarrin/lit with fields, opentracing and json output support.
The design of the API is inspired by Grafana's Loki log aggregation system and structured logging practices. As a result, it heavily favours using fields to log variable data and having log messages be the same regardless of the contextual data.
Example:
log.WithFields(log.Fields{
"userId": user.id,
"requestId": requestId,
}).Info("user logged in successfully")
instead of
log.Info("request %s user %d logged in successfully", user.id, requestId)
Fetch the package:
go get github.com/Strum355/log
and import it:
import (
"github.com/Strum355/log"
)
initialize the logger for development:
log.InitSimpleLogger(&log.Config{...})
or for production using a JSON log parser like FluentD
log.InitJSONlogger(&log.Config{...})