log

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RaceEnabled = false

RaceEnabled is false when the race detector is not active.

View Source
const ReportCrashRPC = "SimManager.ReportCrash"

ReportCrashRPC is the RPC method name for crash reports.

Variables

This section is empty.

Functions

func AnyPointerSlice

func AnyPointerSlice[T any](name string, ptrs []*T) slog.Attr

AnyPointerSlice is similar to slog.Any but takes a slice of pointers; unlike passing a slice of pointers to slog.Any, it logs the values pointed-to by the pointers rather than the pointer values themselves.

func DefaultLogDir added in v0.14.4

func DefaultLogDir(server bool, override string) string

DefaultLogDir returns the log directory the logger would pick given these inputs, without actually constructing a logger. Callers need this when they want to do something with the log directory (such as redirecting stderr into it) before log.New runs.

func RedirectStderrToCrashFile added in v0.14.4

func RedirectStderrToCrashFile(logDir string) string

RedirectStderrToCrashFile is a no-op on non-Windows platforms: vice is built as a console program there, so stderr already has a reasonable destination (terminal or systemd journal).

func RemoveCurrentCrashStderrFile added in v0.14.4

func RemoveCurrentCrashStderrFile()

RemoveCurrentCrashStderrFile is a no-op on non-Windows platforms.

Types

type CrashReport added in v0.14.0

type CrashReport struct {
	Report    string
	System    SystemInfo
	Timestamp time.Time
}

CrashReport is sent via RPC when a crash occurs.

type Logger

type Logger struct {
	*slog.Logger
	LogFile string
	LogDir  string
	Start   time.Time
	// contains filtered or unexported fields
}

func New

func New(server bool, level string, dir string) *Logger

func (*Logger) CatchAndReportCrash

func (l *Logger) CatchAndReportCrash() any

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

Debug wraps slog.Debug to add call stack information (and similarly for the following Logger methods...) Note that we do not wrap the entire slog logging interface, so, for example, WarnContext and Log do not have callstacks included.

We also wrap the logging methods to allow a nil *Logger, in which case debug and info messages are discarded (though warnings and errors still go through to slog.)

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, args ...any)

Debugf is a convenience wrapper that logs just a message and allows printf-style formatting of the provided args.

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, args ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

func (*Logger) Infof

func (l *Logger) Infof(msg string, args ...any)

func (*Logger) ReportCrash added in v0.13.0

func (l *Logger) ReportCrash(err any)

func (*Logger) SetCrashReportClient added in v0.14.0

func (l *Logger) SetCrashReportClient(client *rpc.Client)

SetCrashReportClient sets the RPC client to use for sending crash reports to the server. This should be called after connecting to the server.

func (*Logger) SetGPUInfo added in v0.14.0

func (l *Logger) SetGPUInfo(vendor, renderer string)

SetGPUInfo sets the GPU information for crash reports. This should be called after OpenGL is initialized.

func (*Logger) UploadAndDeleteCrashStderrFiles added in v0.14.4

func (l *Logger) UploadAndDeleteCrashStderrFiles() <-chan struct{}

UploadAndDeleteCrashStderrFiles spawns a background goroutine that scans LogDir for any crash-stderr-*.txt files left over from prior runs, uploads each via the existing crash report RPC, and deletes the file on success. The returned channel is closed once the work is finished (whether the upload succeeded, failed, or timed out), so callers can gate further risky initialization on the upload completing — important for the case where a recurring init-time crash would otherwise kill the next run before the prior report reaches the server.

The current run's file (if any) is skipped so we don't ship a still- being-written log. Empty files (created but never written to because the run exited cleanly before any crash) are deleted without uploading.

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

func (*Logger) Warnf

func (l *Logger) Warnf(msg string, args ...any)

func (*Logger) With

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

type StackFrame

type StackFrame struct {
	File     string `json:"file"`
	Line     int    `json:"line"`
	Function string `json:"function"`
}

func (StackFrame) String

func (f StackFrame) String() string

type StackFrames

type StackFrames []StackFrame

func Callstack

func Callstack(fr []StackFrame) StackFrames

func (StackFrames) String

func (f StackFrames) String() string

func (StackFrames) Strings

func (f StackFrames) Strings() []string

type SystemInfo added in v0.14.0

type SystemInfo struct {
	CPUCores    int
	CPUModel    string
	CPUVendor   string
	CPUFlags    []string
	GPUVendor   string
	GPURenderer string
	GoVersion   string
	OS          string
	Arch        string
}

SystemInfo contains system information for crash reports.

Jump to

Keyboard shortcuts

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