Documentation
¶
Index ¶
- Constants
- func DeleteArchiveEntry(entryPath string) error
- func NewArchiveFileName() string
- func NewArchiveLogFile(archiveDir string) *os.File
- func ParseArchiveFileMetadata(name string) (args string, ts time.Time, err error)
- func RotateArchive(logger *StandardLogger)
- type ArchiveEntry
- type LogMode
- type Logger
- type LoggerOptions
- type StandardLogger
- func (l *StandardLogger) Debugf(msg string, args ...any)
- func (l *StandardLogger) Debugx(msg string, kv ...any)
- func (l *StandardLogger) Error(err error, msg string)
- func (l *StandardLogger) Errorf(msg string, args ...any)
- func (l *StandardLogger) Errorx(msg string, kv ...any)
- func (l *StandardLogger) FatalErr(err error)
- func (l *StandardLogger) Fatalf(msg string, args ...any)
- func (l *StandardLogger) Fatalx(msg string, kv ...any)
- func (l *StandardLogger) Flush() error
- func (l *StandardLogger) Infof(msg string, args ...any)
- func (l *StandardLogger) Infox(msg string, kv ...any)
- func (l *StandardLogger) LogMode() LogMode
- func (l *StandardLogger) Noticef(msg string, args ...any)
- func (l *StandardLogger) Noticex(msg string, kv ...any)
- func (l *StandardLogger) PlainTextDebug(msg string)
- func (l *StandardLogger) PlainTextError(msg string)
- func (l *StandardLogger) PlainTextInfo(msg string)
- func (l *StandardLogger) PlainTextNotice(msg string)
- func (l *StandardLogger) PlainTextSuccess(msg string)
- func (l *StandardLogger) PlainTextWarn(msg string)
- func (l *StandardLogger) Print(data string)
- func (l *StandardLogger) Println(data string)
- func (l *StandardLogger) SetLevel(level int)
- func (l *StandardLogger) SetMode(mode LogMode)
- func (l *StandardLogger) Warnf(msg string, args ...any)
- func (l *StandardLogger) Warnx(msg string, kv ...any)
- type StdErrWriter
- type StdInReader
- type StdOutWriter
Constants ¶
View Source
const ( MaxArchiveSize = 50 LogEntryTimeFormat = "2006-01-02-15-04-05" )
Variables ¶
This section is empty.
Functions ¶
func DeleteArchiveEntry ¶
func NewArchiveFileName ¶
func NewArchiveFileName() string
func NewArchiveLogFile ¶
func RotateArchive ¶
func RotateArchive(logger *StandardLogger)
Types ¶
type ArchiveEntry ¶
func ListArchiveEntries ¶
func ListArchiveEntries(archiveDir string) ([]ArchiveEntry, error)
func (ArchiveEntry) Description ¶
func (e ArchiveEntry) Description() string
func (ArchiveEntry) FilterValue ¶
func (e ArchiveEntry) FilterValue() string
func (ArchiveEntry) Read ¶
func (e ArchiveEntry) Read() (string, error)
func (ArchiveEntry) Title ¶
func (e ArchiveEntry) Title() string
type Logger ¶
type Logger interface {
Flush() error
SetLevel(level int)
SetMode(mode LogMode)
LogMode() LogMode
PlainTextInfo(msg string)
PlainTextNotice(msg string)
PlainTextSuccess(msg string)
PlainTextError(msg string)
PlainTextDebug(msg string)
PlainTextWarn(msg string)
Infof(msg string, args ...any)
Noticef(msg string, args ...any)
Debugf(msg string, args ...any)
Error(err error, msg string)
Errorf(msg string, args ...any)
Warnf(msg string, args ...any)
Fatalf(msg string, args ...any)
Infox(msg string, kv ...any)
Noticex(msg string, kv ...any)
Debugx(msg string, kv ...any)
Errorx(msg string, kv ...any)
Warnx(msg string, kv ...any)
Fatalx(msg string, kv ...any)
Print(data string)
Println(data string)
FatalErr(err error)
}
type LoggerOptions ¶
type LoggerOptions func(*StandardLogger)
func WithArchiveDirectory ¶
func WithArchiveDirectory(path string) LoggerOptions
func WithExitFunc ¶
func WithExitFunc(exit func(msg string, args ...any)) LoggerOptions
func WithMode ¶
func WithMode(mode LogMode) LoggerOptions
func WithOutput ¶
func WithOutput(file *os.File) LoggerOptions
func WithTheme ¶
func WithTheme(theme themes.Theme) LoggerOptions
type StandardLogger ¶
type StandardLogger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(opts ...LoggerOptions) *StandardLogger
NewLogger creates a new instance of StandardLogger with the provided functional options.
Functional options allow you to customize the behavior of the logger:
- WithTheme(theme styles.Theme): Sets the theme for the logger's output.
- WithMode(mode LogMode): Configures the logging mode (e.g., text or JSON).
- WithOutput(file *os.File): Specifies the output file for the logger.
- WithArchiveDirectory(path string): Enables log archiving to the specified directory. If the path is empty, archiving is disabled.
- WithExitFunc(exit func()): Sets a custom function to be called on logger exit.
By default, the logger uses a standard theme, text mode, and writes to os.Stdout.
func (*StandardLogger) Debugf ¶
func (l *StandardLogger) Debugf(msg string, args ...any)
func (*StandardLogger) Debugx ¶
func (l *StandardLogger) Debugx(msg string, kv ...any)
func (*StandardLogger) Error ¶
func (l *StandardLogger) Error(err error, msg string)
func (*StandardLogger) Errorf ¶
func (l *StandardLogger) Errorf(msg string, args ...any)
func (*StandardLogger) Errorx ¶
func (l *StandardLogger) Errorx(msg string, kv ...any)
func (*StandardLogger) FatalErr ¶
func (l *StandardLogger) FatalErr(err error)
func (*StandardLogger) Fatalf ¶
func (l *StandardLogger) Fatalf(msg string, args ...any)
func (*StandardLogger) Fatalx ¶
func (l *StandardLogger) Fatalx(msg string, kv ...any)
func (*StandardLogger) Flush ¶
func (l *StandardLogger) Flush() error
func (*StandardLogger) Infof ¶
func (l *StandardLogger) Infof(msg string, args ...any)
func (*StandardLogger) Infox ¶
func (l *StandardLogger) Infox(msg string, kv ...any)
func (*StandardLogger) LogMode ¶
func (l *StandardLogger) LogMode() LogMode
func (*StandardLogger) Noticef ¶
func (l *StandardLogger) Noticef(msg string, args ...any)
func (*StandardLogger) Noticex ¶
func (l *StandardLogger) Noticex(msg string, kv ...any)
func (*StandardLogger) PlainTextDebug ¶
func (l *StandardLogger) PlainTextDebug(msg string)
func (*StandardLogger) PlainTextError ¶
func (l *StandardLogger) PlainTextError(msg string)
func (*StandardLogger) PlainTextInfo ¶
func (l *StandardLogger) PlainTextInfo(msg string)
func (*StandardLogger) PlainTextNotice ¶
func (l *StandardLogger) PlainTextNotice(msg string)
func (*StandardLogger) PlainTextSuccess ¶
func (l *StandardLogger) PlainTextSuccess(msg string)
func (*StandardLogger) PlainTextWarn ¶
func (l *StandardLogger) PlainTextWarn(msg string)
func (*StandardLogger) Print ¶
func (l *StandardLogger) Print(data string)
func (*StandardLogger) Println ¶
func (l *StandardLogger) Println(data string)
func (*StandardLogger) SetLevel ¶
func (l *StandardLogger) SetLevel(level int)
SetLevel sets the log level for the logger. -1 = Fatal 0 = Info 1 = Debug Default is Info.
func (*StandardLogger) SetMode ¶
func (l *StandardLogger) SetMode(mode LogMode)
func (*StandardLogger) Warnf ¶
func (l *StandardLogger) Warnf(msg string, args ...any)
func (*StandardLogger) Warnx ¶
func (l *StandardLogger) Warnx(msg string, kv ...any)
type StdErrWriter ¶
type StdInReader ¶
Click to show internal directories.
Click to hide internal directories.