logger

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogDirEnv is the environment variable to override the default log directory
	LogDirEnv = "CONFAB_LOG_DIR"
)

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the log file

func Debug

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

Debug logs a debug message (file only, not shown to user)

func Error

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

Error logs an error (file only, not shown to user)

func ErrorPrint

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

ErrorPrint logs an error AND prints to stderr for user visibility

func Info

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

Info logs an info message (file only, not shown to user)

func Init

func Init() error

Init initializes the logger (creates log directory and file).

Test isolation: When running under `go test` (detected via testing.Testing()), if CONFAB_LOG_DIR is not explicitly set, logs are discarded to avoid polluting the real log file. Tests that need to verify log output should set CONFAB_LOG_DIR to a temp directory.

func ResetForTesting

func ResetForTesting()

ResetForTesting resets the singleton state for tests. This allows tests to re-initialize the logger with different settings. Most tests don't need this - the auto-discard behavior handles isolation. Use this when testing logger initialization itself or verifying log output.

func SetSession

func SetSession(externalID, sessionID string)

SetSession sets session IDs that will be included in all log lines

func Warn

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

Warn logs a warning (file only, not shown to user)

Types

type Level

type Level int

Level represents the log level

const (
	DEBUG Level = iota
	INFO
	WARN
	ERROR
)

func (Level) String

func (l Level) String() string

type Logger

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

Logger manages logging to file and optionally stderr

func Get

func Get() *Logger

Get returns the logger instance (initializes if needed)

func (*Logger) Debug

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

Debug logs a debug message

func (*Logger) Error

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

Error logs an error message

func (*Logger) ErrorPrint

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

ErrorPrint logs an error to file AND prints to stderr for user visibility

func (*Logger) Info

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

Info logs an info message

func (*Logger) SetAlsoStderr

func (l *Logger) SetAlsoStderr(enabled bool)

SetAlsoStderr sets whether to also write to stderr

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the minimum log level

func (*Logger) SetSession

func (l *Logger) SetSession(externalID, sessionID string)

SetSession sets session IDs that will be included in all log lines. externalID is the Claude Code session ID, sessionID is the Confab backend session ID. Either can be empty if not yet known.

func (*Logger) SetSessionContext

func (l *Logger) SetSessionContext(ctx string)

SetSessionContext sets a session context that will be included in all log lines. Pass empty string to clear the context.

func (*Logger) Warn

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

Warn logs a warning message

Jump to

Keyboard shortcuts

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