log

package
v0.3.23 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INFO  = Level("info")
	ERROR = Level("error")
	DEBUG = Level("debug")
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

func Debugf

func Debugf(msg string, v ...any)

func Err

func Err(err error)

func Error

func Error(msg string)

func Errorf

func Errorf(msg string, v ...any)

func Info

func Info(msg string)

func Infof

func Infof(msg string, v ...any)

Types

type Level

type Level string

Level is a simple logging level.

type LogMsg

type LogMsg struct {
	Level   Level
	Message string
}

LogMsg that says what to log and it's logging level.

type Logger

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

Logger represents application logger.

func NewLogger

func NewLogger(logFile *os.File, program *tea.Program) *Logger

NewLogger creates a new logger that logs messages into: - logFile - somewhere in UI, currently in status bar via sending LogMsg to the program

func WithFileToLog

func WithFileToLog(file *os.File) *Logger

WithFileToLog sets non-nil file as logger output.

func WithProgramToLog

func WithProgramToLog(program *tea.Program) *Logger

WithProgramToLog sets program where to send log messages.

func (*Logger) LogDebug

func (l *Logger) LogDebug(msg string)

func (*Logger) LogDebugf

func (l *Logger) LogDebugf(msg string, v ...any)

func (*Logger) LogErr

func (l *Logger) LogErr(err error)

LogErr finds mapped error message for passed err and logs it in ERROR level.

func (*Logger) LogError

func (l *Logger) LogError(msg string)

func (*Logger) LogErrorf

func (l *Logger) LogErrorf(msg string, v ...any)

func (*Logger) LogInfo

func (l *Logger) LogInfo(msg string)

func (*Logger) LogInfof

func (l *Logger) LogInfof(msg string, v ...any)

func (*Logger) WithFileToLog

func (l *Logger) WithFileToLog(file *os.File) *Logger

WithFileToLog sets non-nil file as logger output.

func (*Logger) WithProgramToLog

func (l *Logger) WithProgramToLog(program *tea.Program) *Logger

WithProgramToLog sets program where to send log messages.

Jump to

Keyboard shortcuts

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