package
1.3.4
Repository: https://github.com/avakarev/go-util.git
Documentation: pkg.go.dev

# README

logutil

Helper to initialize and set defaults for zerolog

Install

go get github.com/avakarev/go-util/logutil

Usage

Initialize go-logutil before any other packages in your app for consistent logging format.

package main

import (
	"github.com/avakarev/go-util/logutil"
	"github.com/rs/zerolog/log"
)

func main() {
	logutil.MustInit()

	log.Debug().Msg("Hello World!")
}

It respects LOG_LEVEL environment variable and sets global level for zerolog. If not set, default log level is info.

See allowed logging levels in zerolog's documentation: https://github.com/rs/zerolog#leveled-logging.

License

go-logutil is licensed under MIT license. (see LICENSE)

# Functions

Init initializes logger.
IsDebug checks whether log level is `debug`.
MustInit is like Init but panics in case of error.
SetLevel sets `zerolog`'s global level.

# Constants

DefaultLevel is default log level.