Skip to content

spacetab-io/logs-go

Repository files navigation

logs-go

CircleCI codecov

Wrapper for zerolog tuned to work with configuration and sentry hook.

Usage

Initiate new logger with filled log.Config and use it as common zerolog

package main

import (
	log "github.com/spacetab-io/logs-go/v2"
)

func main() {
	conf := log.Config{
		Level:  "warn",
		Format: "text",
		Caller: &log.CallerConfig{
			Disabled:         false,
			CallerSkipFrames: 2,
		},
		Sentry: &log.SentryConfig{
			Enable: true,
			DSN:    "http://dsn.sentry.com",
		},
	}

	if err := log.Init("test", conf, "logs-go", "v2.*.*", nil); err != nil {
		panic(err)
	}

	log.Warn().Msg("log some warning")
}

Licence

The software is provided under MIT Licence.