Skip to content

Strum355/log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stroom Log™

Build Status GoDoc Go report

Simple logger inspired by bwmarrin/lit with fields, opentracing and json output support.

Design Philosophy

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)

Usage

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{...})