/logger

Primary LanguageGoMIT LicenseMIT

logger

This is a simple wrapper on Zap library.

It provides a simple configuration and a broad set of methods.

Usage example:

package main

import "github.com/w84thesun/logger" 

func main() {
    log, err := logger.New(logger.DefaultConfig)
    if err != nil {
        panic(err)
    }
    log.Info("some message")
}

The result would be:

{
  "level":"info",
  "@timestamp":"2009-11-10T23:00:00Z",
  "message":"some message",
  "service":"awesome-service",
  "namespace":"awesome-namespace"
}

Spaces would be trimmed, added here for readability.

To use some custom fields:

package main

import "github.com/w84thesun/logger" 

func main() {
    log, err := logger.New(logger.DefaultConfig)
    if err != nil {
        panic(err)
    }
    log.With(logger.Fields{"some_field": "test", "another_field": 123}).Info("some message")
}

Which results in:

{
  "level":"info",
  "@timestamp":"2009-11-10T23:00:00Z",
  "message":"some message",
  "service":"awesome-service",
  "namespace":"awesome-namespace",
  "some_field":"test",
  "another_field":123
}