log

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package log is meant to provide a global logger for the application and provide logging functionality interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(format string, v ...any)

Debug runs Logger.Debug with a global logger.

func DebugTimer added in v0.14.0

func DebugTimer(name string) func()

DebugTimer returns a function that prints the name argument and the elapsed time between the call to timer and the call to the returned function. The returned function is intended to be used in a defer statement:

defer DebugTimer("sum")().

func Err

func Err(format string, v ...any)

Err runs Logger.Err with a global logger.

func Fatal

func Fatal(format string, v ...any)

Fatal runs Logger.Fatal with a global logger.

func Info

func Info(format string, v ...any)

Info runs Logger.Info with a global logger.

func Panic

func Panic(format string, v ...any)

Panic runs Logger.Panic with a global logger.

func SetGlobalLogger

func SetGlobalLogger(newL Logger)

SetGlobalLogger sets a package default global logger.

func SetLevel

func SetLevel(lvl Level)

SetLevel runs Logger.SetLevel with a global logger.

func Warn

func Warn(format string, v ...any)

Warn runs Logger.Warn with a global logger.

Types

type Config

type Config struct {
	Prefix    string
	Verbosity Level
}

Config stores configuration for a logger.

type Level

type Level int

Level defines a log level.

const (
	DebugLvl Level = iota
	InfoLvl
	WarnLvl
	ErrLvl
	FatalLvl
)

Log level constants.

type Logger

type Logger interface {
	Debug(format string, v ...any)
	Info(format string, v ...any)
	Warn(format string, v ...any)
	Err(format string, v ...any)
	Panic(format string, v ...any)
	Fatal(format string, v ...any)
	SetLevel(Level)
}

Logger interface defines leveled logging functionality.

func NewNoopLogger

func NewNoopLogger() Logger

NewNoopLogger creates a new logger that doesn't do anything.

func NewPlainLogger

func NewPlainLogger(out *os.File, err *os.File, cfg *Config) Logger

NewPlainLogger creates a CLI plain text logger.

Jump to

Keyboard shortcuts

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