logger

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger incapsulates logger functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLogger added in v1.4.0

type AppLogger struct {
	// contains filtered or unexported fields
}

AppLogger is a simple logger that writes messages to a file.

func Create added in v1.4.0

func Create(appPath, userSetLogLevel string) (*AppLogger, error)

Create - creates a new logger with a specific log level. appPath - where log file will be stored. userSetLogLevel - user-defined log level (debug or info).

func Get added in v1.4.0

func Get() *AppLogger

Get - returns application state.

func (*AppLogger) Close added in v1.4.0

func (l *AppLogger) Close()

Close - closes the log file.

func (*AppLogger) Debug added in v1.4.0

func (l *AppLogger) Debug(format string, args ...any)

Debug - prints debug message if log level is set to debug.

func (*AppLogger) Error added in v1.4.0

func (l *AppLogger) Error(format string, args ...any)

Error - prints an error message regardless of the log level.

func (*AppLogger) Info added in v1.4.0

func (l *AppLogger) Info(format string, args ...any)

Info - prints info message if log level is set to debug or info.

func (*AppLogger) Warn added in v1.4.0

func (l *AppLogger) Warn(format string, args ...any)

Warn - prints a warning message regardless of the log level.

type LogLevel added in v0.2.0

type LogLevel int

LogLevel is a subject for revising. Probably it's better to have a boolean flag to switch on/off debug logging.

const (
	// LevelDebug - when log level is 'debug', then all messages will be printed into the log file.
	LevelDebug LogLevel = iota
	// LevelInfo - when log level is 'info', then only 'info' and more severe messages will be printed into the log file.
	LevelInfo
)

type Once added in v1.4.0

type Once interface {
	Do(func())
}

Once - this interface is used to avoid sync.Once restrictions in unit-tests.

Jump to

Keyboard shortcuts

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