logging

package
v0.0.0-...-b2804b8 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: OSL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logging provides a standardized logging interface for CUDly. This package wraps the standard log package and provides structured logging capabilities with log levels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug logs a debug message using the default logger.

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a formatted debug message using the default logger.

func Error

func Error(msg string)

Error logs an error message using the default logger.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a formatted error message using the default logger.

func Info

func Info(msg string)

Info logs an info message using the default logger.

func Infof

func Infof(format string, args ...interface{})

Infof logs a formatted info message using the default logger.

func SetLevel

func SetLevel(level string)

SetLevel sets the logging level.

func SetLevelValue

func SetLevelValue(level Level)

SetLevelValue sets the logging level using a Level value.

func SetOutput

func SetOutput(w io.Writer) io.Writer

SetOutput redirects the default logger's output to w and returns the previous io.Writer so callers can restore it (e.g. in a test t.Cleanup). The default logger binds os.Stderr at init() time, so reassigning the os.Stderr variable does not redirect it; this is the supported seam for capturing default-logger output in tests.

func Warn

func Warn(msg string)

Warn logs a warning message using the default logger.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted warning message using the default logger.

Types

type Config

type Config struct {
	Level      string
	Output     io.Writer
	Prefix     string
	TimeFormat string
}

Config holds logger configuration.

type Level

type Level int

Level represents a logging level.

const (
	// LevelDebug is for detailed debugging information.
	LevelDebug Level = iota
	// LevelInfo is for general informational messages.
	LevelInfo
	// LevelWarn is for warning messages.
	LevelWarn
	// LevelError is for error messages.
	LevelError
)

func GetLevel

func GetLevel() Level

GetLevel returns the current log level.

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a string log level.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides structured logging capabilities.

level is stored as an atomic.Int32 so that SetLevel/SetLevelValue (called at runtime, sometimes after worker goroutines have launched) and the level reads performed by every Debug/Info/Warn/Error call are race-free under the concurrent fan-out, which logs from many goroutines.

func GetDefaultLogger

func GetDefaultLogger() *Logger

GetDefaultLogger returns the default logger instance.

func New

func New(cfg Config) *Logger

New creates a new logger with the given configuration.

func With

func With(key string, value interface{}) *Logger

With creates a new logger with additional metadata from the default logger.

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug logs a debug message.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted debug message.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs an error message.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs an info message.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs a formatted info message.

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs a warning message.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message.

func (*Logger) With

func (l *Logger) With(key string, value interface{}) *Logger

With creates a new logger with additional metadata.

Jump to

Keyboard shortcuts

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