logger

package module
v0.0.0-...-f9bb5aa Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 1 Imported by: 1

README

logger

Wrapper around a pterm.Logger to enable file logging

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = Logger{
	Loggers: []*pterm.Logger{
		pterm.DefaultLogger.WithLevel(pterm.LogLevelInfo),
	},
}
View Source
var DisabledLogger = Logger{}

Functions

This section is empty.

Types

type Logger

type Logger struct {
	Loggers []*pterm.Logger
}

Logger is a custom logger that wraps multiple pterm.Loggers. This enables printing to multiple locations such as the terminal and to file, using different formats.

func (Logger) Args

func (l Logger) Args(args ...any) []pterm.LoggerArgument

Args converts any arguments to a slice of pterm.LoggerArgument.

func (Logger) ArgsFromMap

func (l Logger) ArgsFromMap(m map[string]any) []pterm.LoggerArgument

ArgsFromMap converts a map to a slice of pterm.LoggerArgument.

func (Logger) Debug

func (l Logger) Debug(msg string, args ...[]pterm.LoggerArgument)

Debug prints a debug log.

func (Logger) Error

func (l Logger) Error(msg string, args ...[]pterm.LoggerArgument)

Error prints an error log.

func (Logger) Fatal

func (l Logger) Fatal(msg string, args ...[]pterm.LoggerArgument)

Fatal prints a fatal log and exits the program.

func (Logger) Info

func (l Logger) Info(msg string, args ...[]pterm.LoggerArgument)

Info prints an info log.

func (Logger) Trace

func (l Logger) Trace(msg string, args ...[]pterm.LoggerArgument)

Trace prints a trace log.

func (Logger) Warn

func (l Logger) Warn(msg string, args ...[]pterm.LoggerArgument)

Warn prints a warning log.

func (Logger) WithCaller

func (l Logger) WithCaller(b ...bool) *Logger

WithCaller enables or disables the caller.

func (Logger) WithCustomLogger

func (l Logger) WithCustomLogger(logger *pterm.Logger) *Logger

WithCustomLogger appends the logger to the list of loggers. A log call propagates to all the stored loggers.

func (Logger) WithLevel

func (l Logger) WithLevel(level pterm.LogLevel) *Logger

WithLevel sets the log level of the logger.

Jump to

Keyboard shortcuts

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