Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/strum355/log
Stroom log
https://github.com/strum355/log
json-logging logging structured-logging
Last synced: 3 months ago
JSON representation
Stroom log
- Host: GitHub
- URL: https://github.com/strum355/log
- Owner: Strum355
- License: mit
- Created: 2019-08-02T14:27:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-08T11:30:59.000Z (over 4 years ago)
- Last Synced: 2024-06-21T18:48:32.229Z (7 months ago)
- Topics: json-logging, logging, structured-logging
- Language: Go
- Size: 19.5 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stroom Log™
[![Build Status](https://cloud.drone.io/api/badges/Strum355/log/status.svg)](https://cloud.drone.io/Strum355/log)
[![GoDoc](https://godoc.org/github.com/Strum355/log?status.svg)](https://godoc.org/github.com/Strum355/log)
[![Go report](https://goreportcard.com/badge/Strum355/log)](https://goreportcard.com/report/Strum355/log)Simple logger inspired by [bwmarrin/lit](https://github.com/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:
```go
log.WithFields(log.Fields{
"userId": user.id,
"requestId": requestId,
}).Info("user logged in successfully")
```instead of
```go
log.Info("request %s user %d logged in successfully", user.id, requestId)
```## Usage
Fetch the package:
```shell
go get github.com/Strum355/log
```and import it:
```go
import (
"github.com/Strum355/log"
)
```initialize the logger for development:
```go
log.InitSimpleLogger(&log.Config{...})
```or for production using a JSON log parser like FluentD
```go
log.InitJSONlogger(&log.Config{...})
```