Categorygithub.com/opalmer/logrusutil
modulepackage
1.0.2
Repository: https://github.com/opalmer/logrusutil.git
Documentation: pkg.go.dev

# README

Logrus Wrapper

Build Status codecov Go Report Card GoDoc

This project provides very basic wrappers for logrus including:

  • Log level parsing and handling.
  • Hooks for adding additional information to log messages.

Contributions are welcome but before opening a PR consider if your request would be better served as a contribution directly to the logrus project. This project was initially created so a few different projects could share the same code.

package main

import (
	"github.com/opalmer/logrusutil"
	"github.com/Sirupsen/logrus"
)

func main() {
	// Setup the root logger and hooks.
	if err := logrusutil.ConfigureLogger(logrus.StandardLogger(), logrusutil.NewConfig()); err != nil {
		panic(err)
	}
}

Case Sensitivity

The logrus project was renamed at one point from:

github.com/Sirupsen/logrus

To:

github.com/sirupsen/logrus

This causes conflicts to occur in certain cases if one or more of your dependencies are using the old import path. This project uses sirupsen which reflects what the majority of projects are using today.

# Functions

ConfigureLogger will use the provided configuration to setup the root logrus logger.
NewCallerHook constructs and returns logrus.Hook implementation based on the provided configuration.
NewConfig produces a *Config struct with reasonable defaults.

# Constants

No description provided by the author
nolint.
No description provided by the author
DisabledLevel may be passed into a *Config struct to disable logging and discard output.
EmptyFormat is passed to MockFieldLogger.LevelFunc when there's no format associated with a log entry.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NoLevel and the following constants are used by MockFieldLogger to indicate to MockFieldLogger.levelFunc what function is being called by logrus.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

DefaultCallerHookField sets the default field name that the CallerHook hook will apply to a log entry.
DefaultHookLevel is the default level where hooks will contribute log messages.
DefaultHookStackLevel is the level at which the hook will apply.
DefaultLevel is the default log level used in NewConfig().
ErrLevelNotProvided is returned when a level was not provided in the config struct.

# Structs

CallerHook is a logrus hook which applies information about the caller to log messages.
Config is used to provided configuration information.
MockFieldLogger implements logrus.FieldLogger.

# Type aliases

Function is a type used by the constants below.