mlog

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log = logger{/* contains filtered or unexported fields */}

Functions

func Flush

func Flush()

Flush flushes the log buffer to ensure all pending messages are written. Call this before starting progress bars or other terminal output that depends on cursor position.

func GetBaseLogDir

func GetBaseLogDir() string

GetBaseLogDir returns the base log directory (parent of all run directories)

func GetLogDir

func GetLogDir() string

GetLogDir returns the per-run log directory path (where mithril.log and artifacts go)

func GetLogPath

func GetLogPath() string

GetLogPath returns the path to the current log file

func GetRunID

func GetRunID() string

GetRunID returns the run ID for the current session

func Initialize

func Initialize(cfg LogConfig, runID string) error

Initialize sets up file logging with the given config and run ID. If dir is empty, only stdout logging is used.

Directory structure:

<dir>/
├── runs.log                               # Append-only log tracking all runs
├── latest -> <run_dir>/                   # Symlink to latest run directory
├── 20250104-120000Z_abc123_12345678/      # Per-run directory
│   ├── mithril.log                        # Main log file
│   ├── config.toml                        # Copy of config used for this run
│   └── leader_schedule/                   # Leader schedule artifacts
│       ├── epoch905_local_12345678_validators.csv
│       ├── epoch905_local_12345678_skipped.csv
│       ├── epoch905_local_12345678_summary.txt
│       └── mismatch_12345678.log
└── 20250104-130000Z_def456_87654321/
    └── ...

func SaveRunConfig

func SaveRunConfig(configContent []byte) error

SaveRunConfig saves a copy of the config to the run directory. Should be called after Initialize with the full config content.

func Shutdown

func Shutdown()

Shutdown flushes all pending writes and closes the log file

Types

type LogConfig

type LogConfig struct {
	Dir        string // Log directory (default: /mnt/mithril-logs)
	Level      string // Log level: debug, info, warn, error
	ToStdout   bool   // Also write to stdout (default: true)
	MaxSizeMB  int    // Max log file size in MB before rotation
	MaxAgeDays int    // Delete logs older than this many days
	MaxBackups int    // Keep up to N old log files
}

LogConfig holds logging configuration (mirrors config.LogConfig)

func DefaultConfig

func DefaultConfig() LogConfig

DefaultConfig returns sensible defaults for logging

type LogLevel

type LogLevel int

LogLevel represents the logging level

const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
)

Jump to

Keyboard shortcuts

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