log

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeKeyArtifact   AttributeKey = "Artifact"
	AttributeKeyLanguage                = "Language"
	AttributeKeyModel                   = "Model"
	AttributeKeyRepository              = "Repository"
	AttributeKeyResultPath              = "ResultPath"
	AttributeKeyRun                     = "Run"
	AttributeKeyTask                    = "Task"
)
View Source
const (
	FlagMessageOnly = 0
	FlagDate        = 1 << iota
	FlagTime
	FlagStandard = FlagDate | FlagTime
)

Variables

This section is empty.

Functions

func Attribute added in v0.6.0

func Attribute(key AttributeKey, value any) (attribute slog.Attr)

Attribute returns a logging attribute.

func CleanModelNameForFileSystem added in v0.6.0

func CleanModelNameForFileSystem(modelName string) (modelNameCleaned string)

CleanModelNameForFileSystem cleans a model name to be useable for directory and file names on the file system.

func CloseOpenLogFiles added in v0.6.0

func CloseOpenLogFiles()

CloseOpenLogFiles closes the files that were opened by some logger.

Types

type AttributeKey added in v0.6.0

type AttributeKey string

AttributeKey defines a key for attributes handed to the structural logger.

type Flags added in v0.6.0

type Flags int

Flags defines how log messages should be printed.

type Logger

type Logger struct {
	*slog.Logger
}

Logger holds a logger to log to.

func Buffer

func Buffer() (buffer *bytesutil.SynchronizedBuffer, logger *Logger)

Buffer returns a logger that writes to a buffer.

func File

func File(path string) (logger *Logger, loggerClose func(), err error)

File returns a logger that writes to a file.

func STDOUT

func STDOUT() (logger *Logger)

STDOUT returns a logger that writes to STDOUT.

func (*Logger) Fatal added in v0.6.0

func (l *Logger) Fatal(v ...any)

Fatal is equivalent to "Print" followed by a "os.Exit(1)".

func (*Logger) Panic added in v0.6.0

func (l *Logger) Panic(message string)

Panic is equivalent to "Print" followed by a panic.

func (*Logger) Panicf added in v0.6.0

func (l *Logger) Panicf(format string, args ...any)

Panicf is equivalent to "Printf" followed by a panic.

func (*Logger) Print added in v0.6.0

func (l *Logger) Print(message string)

Print logs the given message at the "info" level.

func (*Logger) PrintWith added in v0.6.0

func (l *Logger) PrintWith(message string, args ...any)

PrintWith logs the given message at the "info" level.

func (*Logger) Printf added in v0.6.0

func (l *Logger) Printf(format string, args ...any)

Printf logs the given message at the "info" level.

func (*Logger) SetFlags added in v0.6.0

func (l *Logger) SetFlags(flags Flags)

SetFlags sets the flags defining how log messages should be printed.

func (*Logger) With added in v0.6.0

func (l *Logger) With(key AttributeKey, value any) *Logger

With returns a Logger that includes the given attributes in each output operation.

func (*Logger) Writer added in v0.6.0

func (l *Logger) Writer() (writer io.Writer)

Writer returns a writer for writing to the logging output destination.

Jump to

Keyboard shortcuts

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