log

package
v0.0.0-...-f308040 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package log implements a basic level based logger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileLogger

type FileLogger struct {
	// Level indicates which maximum level this logger actually forwards to the file
	Level Level
	// contains filtered or unexported fields
}

FileLogger defines the type of logger that this package implements As the name suggests, it saves the log to a file.

var Logger *FileLogger

Logger is the global logger instance

func (*FileLogger) Close

func (logger *FileLogger) Close() error

Close closes the logger by closing the internal file.

func (*FileLogger) Debugf

func (logger *FileLogger) Debugf(msg string, params ...interface{})

Debugf logs a message with parameters as level LevelDebug.

func (*FileLogger) Errorf

func (logger *FileLogger) Errorf(msg string, params ...interface{})

Errorf logs a message with parameters as level LevelError.

func (*FileLogger) Fatalf

func (logger *FileLogger) Fatalf(msg string, params ...interface{})

Fatalf logs a message with parameters as level LevelFatal.

func (*FileLogger) Infof

func (logger *FileLogger) Infof(msg string, params ...interface{})

Infof logs a message with parameters as level LevelInfo.

func (*FileLogger) Inherit

func (logger *FileLogger) Inherit(err error, msg string)

Inherit logs an error with a message and params using the error level verbosity of the error. The message is always prefixed with the error.

func (*FileLogger) Init

func (logger *FileLogger) Init(lvl Level, dir string) error

Init initializes the logger by forwarding a max level 'level' and a directory 'directory' where the log should be stored If the logger cannot be initialized, for example an error in opening the log file, an error is returned.

func (*FileLogger) Warningf

func (logger *FileLogger) Warningf(msg string, params ...interface{})

Warningf logs a message with parameters as level LevelWarning.

type Level

type Level int8

Level is the level of log, e.g. debug

const (
	// LevelNotSet indicates level not set, not allowed.
	LevelNotSet Level = iota

	// LevelDebug indicates that the message is not an error but is there for debugging.
	LevelDebug

	// LevelInfo indicates that the message is not an error but is there for additional information.
	LevelInfo

	// LevelWarning indicates only a warning, the app still functions.
	LevelWarning

	// LevelError indicates a generic error, the app still functions but some functionality might not work.
	LevelError

	// LevelFatal indicates a fatal error, the app cannot function correctly when such an error occurs.
	LevelFatal
)

func (Level) String

func (e Level) String() string

String returns the string of each level.

Jump to

Keyboard shortcuts

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