logging

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package logging provides structured logging using slog. Logs are written to .co/debug.log in append mode.

Index

Constants

View Source
const (
	// LogFileName is the name of the debug log file.
	LogFileName = "debug.log"
	// ConfigDir is the directory name for project configuration.
	ConfigDir = ".co"
)

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the log file.

func Debug

func Debug(msg string, args ...any)

Debug logs at debug level.

func DebugContext

func DebugContext(ctx context.Context, msg string, args ...any)

DebugContext logs at debug level with context.

func Error

func Error(msg string, args ...any)

Error logs at error level.

func ErrorContext

func ErrorContext(ctx context.Context, msg string, args ...any)

ErrorContext logs at error level with context.

func Info

func Info(msg string, args ...any)

Info logs at info level.

func InfoContext

func InfoContext(ctx context.Context, msg string, args ...any)

InfoContext logs at info level with context.

func Init

func Init(projectRoot string) error

Init initializes the logger with the project root path. Logs are written to <projectRoot>/.co/debug.log in append mode. If projectRoot is empty, logging is disabled (writes to io.Discard).

func Logger

func Logger() *slog.Logger

Logger returns the default logger. If not initialized, returns a no-op logger.

func Warn

func Warn(msg string, args ...any)

Warn logs at warning level.

func WarnContext

func WarnContext(ctx context.Context, msg string, args ...any)

WarnContext logs at warning level with context.

func With

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

With returns a logger with the given attributes.

func WithGroup

func WithGroup(name string) *slog.Logger

WithGroup returns a logger with the given group.

Types

This section is empty.

Jump to

Keyboard shortcuts

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