log

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CrashReportPath = "/crash"
View Source
const CrashReportPort = "6504"
View Source
const CrashReportServer = "localhost"
View Source
const CrashReportURL = "http://" + CrashReportServer + ":" + CrashReportPort + CrashReportPath

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*slog.Logger
	LogFile string
	LogDir  string
	Start   time.Time
}

func New

func New(server bool, level string, dir string) *Logger

func (*Logger) CatchAndReportCrash added in v0.11.7

func (l *Logger) CatchAndReportCrash() any

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

Debug wraps slog.Debug to add call stack information (and similarly for the following Logger methods...) Note that we do not wrap the entire slog logging interface, so, for example, WarnContext and Log do not have callstacks included.

We also wrap the logging methods to allow a nil *Logger, in which case debug and info messages are discarded (though warnings and errors still go through to slog.)

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, args ...any)

Debugf is a convenience wrapper that logs just a message and allows printf-style formatting of the provided args.

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, args ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) Infof

func (l *Logger) Infof(msg string, args ...any)

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

func (*Logger) Warnf

func (l *Logger) Warnf(msg string, args ...any)

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

type StackFrame

type StackFrame struct {
	File     string `json:"file"`
	Line     int    `json:"line"`
	Function string `json:"function"`
}

func Callstack

func Callstack(fr []StackFrame) []StackFrame

Jump to

Keyboard shortcuts

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