log

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvironmentProduction production log environment.
	EnvironmentProduction = LogEnvironment("production")
	// EnvironmentDevelopment development log environment.
	EnvironmentDevelopment = LogEnvironment("development")
)

Variables

This section is empty.

Functions

func Debugf

func Debugf(template string, args ...interface{})

Debugf calls log.Debugf on the root Logger.

func Error

func Error(args ...interface{})

Error calls log.Error on the root Logger.

func Errorf

func Errorf(template string, args ...interface{})

Errorf calls log.Errorf on the root logger and stores the error message into the ErrorFile.

func Fatal

func Fatal(args ...interface{})

Fatal calls log.Fatal on the root Logger.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf calls log.Fatalf on the root Logger.

func Info

func Info(args ...interface{})

Info calls log.Info on the root Logger.

func Infof

func Infof(template string, args ...interface{})

Infof calls log.Infof on the root Logger.

func InitLogger

func InitLogger(cfg Config) error

InitLogger creates the logger with defined level. Outputs parameter defines the outputs where the logs will be sent. By default, outputs contains "stdout", which prints the logs at the output of the process. To add a log file as output, the path should be added at the outputs array. To avoid printing the logs but storing them on a file, can use []string{"pathtofile.log"}

func Warn

func Warn(args ...interface{})

Warn calls log.Warn on the root Logger.

func Warnf

func Warnf(template string, args ...interface{})

Warnf calls log.Warnf on the root Logger.

func WithFields

func WithFields(keyValuePairs ...interface{}) *zap.SugaredLogger

WithFields returns a new Logger (derived from the root one) with additional fields as per keyValuePairs. The root Logger instance is not affected.

Types

type Config

type Config struct {
	// Environment defining the log format ("production" or "development").
	Environment LogEnvironment `mapstructure:"Environment" jsonschema:"enum=production,enum=development"`
	// Level of log. As lower value more logs are going to be generated
	Level string `mapstructure:"Level" jsonschema:"enum=debug,enum=info,enum=warn,enum=error,enum=dpanic,enum=panic,enum=fatal"`
	// Outputs
	Outputs []string `mapstructure:"Outputs"`
}

Config for log

type LogEnvironment

type LogEnvironment string

LogEnvironment represents the possible log environments.

Jump to

Keyboard shortcuts

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