logging

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides a structured logging interface compatible with slog levels and common logging utilities for the MindTrial application.

Index

Constants

View Source
const (
	LevelTrace = slog.Level(-8) // most verbose
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError // least verbose
)

Common logging levels for structured logging.

View Source
const UnknownLogValue = "<unknown>"

UnknownLogValue is the placeholder text used when logging nil or unknown values.

Variables

This section is empty.

Functions

func FormatLogInt64

func FormatLogInt64(value *int64) string

FormatLogInt64 formats an int64 pointer value for logging. If the pointer is nil, it returns a placeholder value.

func FormatLogText

func FormatLogText(lines []string) string

FormatLogText formats a slice of strings for logging with tab indentation and double-newline separation. If the slice is empty, it returns a tab-indented placeholder value.

Types

type Logger

type Logger interface {
	// Message logs a message at the specified level with optional format arguments.
	Message(ctx context.Context, level slog.Level, msg string, args ...any)

	// Error logs an error at the specified level with optional format arguments.
	Error(ctx context.Context, level slog.Level, err error, msg string, args ...any)

	// WithContext returns a new Logger that appends the specified context to the existing prefix.
	// This allows for hierarchical logging where components can add their context
	// without affecting the original logger instance. Each call extends the prefix chain.
	WithContext(context string) Logger
}

Logger defines a generic logging interface following slog style with log levels. It provides structured logging capabilities for both regular messages and error handling.

Jump to

Keyboard shortcuts

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