log

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package log implements a simple logger that directly uses the logrus library. It can initializes multiple instances, each of which log with their own fields and are safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(levelStr, logFile string) error

InitLogger sets the internal logger instance to the given level and log file. Logs to stdout if logFile is an empty string.

It also initializes the logger in the go-perun library.

Types

type Fields added in v0.6.0

type Fields = logrus.Fields

Fields is a collection of field to be passed to the Logger.

type Logger

type Logger = logrus.FieldLogger

Logger is for now, a type alias of Logrus.FieldLogger that defines a broad interface for logging.

func NewDerivedLoggerWithField added in v0.5.0

func NewDerivedLoggerWithField(parentLogger Logger, key string, value interface{}) Logger

NewDerivedLoggerWithField returns a logger that inherits all properties of the parent logger, and add the given fields for each log entry.

Panics if parent logger is nil.

func NewLogger added in v0.6.0

func NewLogger() Logger

NewLogger returns the package level logger.

If the internal logger instance is not initialized before this call, it is initialized to "debug" level and logs to the standard output (stdout).

func NewLoggerWithField

func NewLoggerWithField(key string, value interface{}) Logger

NewLoggerWithField returns a logger that logs with the given fields. It is derived from the internal logger instance of this package and uses the same log level and log file.

If the internal logger instance is not initialized before this call, it is initialized to "debug" level and logs to the standard output (stdout).

Jump to

Keyboard shortcuts

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