logutil

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 3 Imported by: 2

README

logutil

Utilities to init and set defaults for zerolog

Install

go get github.com/avakarev/go-logutil

Usage

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

package main

import (
	"github.com/avakarev/go-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)

Documentation

Index

Constants

View Source
const DefaultLevel = "info"

DefaultLevel is default log level

Variables

This section is empty.

Functions

func Init

func Init() error

Init initializes logger

func IsDebug

func IsDebug() bool

IsDebug checks whether log level is `debug`

func MustInit

func MustInit()

MustInit is like Init but panics in case of error

func SetLevel

func SetLevel(name string) error

SetLevel sets `zerolog`'s global level

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL