log

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AttributeKeyLanguage holds the key for the "Language" attribute.
	AttributeKeyLanguage = AttributeKey("Language")
	// AttributeKeyModel holds the key for the "Model" attribute.
	AttributeKeyModel = AttributeKey("Model")
	// AttributeKeyRepository holds the key for the "Repository" attribute.
	AttributeKeyRepository = AttributeKey("Repository")
	// AttributeKeyResultPath holds the key for the "ResultPath" attribute.
	AttributeKeyResultPath = AttributeKey("ResultPath")
	// AttributeKeyTask holds the key for the "Task" attribute.
	AttributeKeyTask = AttributeKey("Task")
)

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 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) Fatalf added in v1.0.0

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

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

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) PrintfWithoutMeta added in v1.0.0

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

PrintfWithoutMeta prints a message without any timestamp, log level or origin program counter.

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.

Jump to

Keyboard shortcuts

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