Documentation
¶
Index ¶
Constants ¶
const ( // MaxCaptureLineBytes is the per-line capture cap for mihomo stdout/stderr. MaxCaptureLineBytes = 16 << 10 // MaxExportRecordBytes is the per-record export parse cap. MaxExportRecordBytes = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
Config is the runtime logging level and rotation limits.
func BootstrapConfig ¶
func BootstrapConfig() Config
BootstrapConfig is the conservative TUI bootstrap: debug, 100 MiB, 10 files.
type FailureClass ¶
type FailureClass string
FailureClass is a stable, rate-limited stderr category.
const ( FailureDropped FailureClass = "dropped" FailureWrite FailureClass = "write" FailureRotate FailureClass = "rotate" FailureCleanup FailureClass = "cleanup" )
type FailureReporter ¶
type FailureReporter interface {
Report(class FailureClass, err error)
}
FailureReporter records classified logging failures.
func NewFailureReporter ¶
NewFailureReporter writes rate-limited, redacted failure lines without full paths.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group applies one config to multiple runtimes (daemon and mihomo).
func (*Group) Apply ¶
Apply swaps config on every target, then converges archives one by one. It must not call Runtime.Apply per target.
type LineCaptureWriter ¶
type LineCaptureWriter interface {
io.WriteCloser
Flush() error
}
LineCaptureWriter splits arbitrary stdout/stderr chunks into JSONL records.
func NewLineCaptureWriter ¶
NewLineCaptureWriter returns a writer that logs each logical line at level with stream set. Write returns len(p), nil unless the writer is closed.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor applies immutable exact-secret and generic redaction rules to log text and attrs.
func NewRedactor ¶
NewRedactor builds a redactor and registers optional exact secrets.
func (*Redactor) ReplaceAttr ¶
ReplaceAttr recursively redacts slog attributes. Sensitive keys and sensitive ancestor groups replace values with ***; strings, errors, and LogValuer results run through String.
func (*Redactor) ReplaceExact ¶
ReplaceExact replaces the exact-secret snapshot. Empty and too-short values are dropped; remaining values are copied and sorted longest-first. Generic regexes are package-level.
type RotatingWriter ¶
type RotatingWriter struct {
// contains filtered or unexported fields
}
RotatingWriter appends full JSONL records with overflow-safe rotation.
func OpenRotatingWriter ¶
func OpenRotatingWriter(ctx context.Context, opts RotatorOptions) (*RotatingWriter, error)
OpenRotatingWriter creates the lock, converges archives, and creates the base file. The initial lock wait uses the earlier of the caller deadline and the hard write-wait bound. On failure, acquired resources are closed.
func (*RotatingWriter) Apply ¶
func (w *RotatingWriter) Apply(ctx context.Context, cfg Config)
Apply atomically stores cfg, then waits min(ctx deadline, WriteWait) for the exclusive lock and converges archives. Lock timeout or ctx cancel skip maintenance; the swapped config is kept. After the lock is held, ReadDir and Remove are not canceled.
func (*RotatingWriter) Close ¶
func (w *RotatingWriter) Close() error
Close closes the current write handle and lock. It does not close PrivateFS.
func (*RotatingWriter) Dropped ¶
func (w *RotatingWriter) Dropped() uint64
Dropped returns the number of records dropped because the write lock wait failed.
func (*RotatingWriter) Write ¶
func (w *RotatingWriter) Write(p []byte) (n int, err error)
Write appends one complete JSONL record. It takes the process mutex, then an exclusive advisory lock (WriteWait, default 250ms). After the lock it opens and Stats the base file. A lock wait failure drops the whole record.
type RotatorOptions ¶
type RotatorOptions struct {
BasePath string
Config Config
PrivateFS *platform.PrivateFS
OpenLock func(*platform.PrivateFS, string) (platform.AdvisoryLock, error)
WriteWait time.Duration
Reporter FailureReporter
}
RotatorOptions opens a process-safe rotating JSONL writer.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns a slog logger, LevelVar, and rotating writer for one log file.
func Open ¶
func Open(ctx context.Context, opts RuntimeOptions) (*Runtime, error)
Open creates the base log file and returns a runtime. ctx cancel aborts the initial lock wait. The shared PrivateFS is not owned by the runtime.
func (*Runtime) Apply ¶
Apply swaps level and rotator limits, then converges archives. A canceled context still completes the in-memory swap.
func (*Runtime) Close ¶
Close closes the rotator, lock, and current write handle. It does not close the shared PrivateFS.
func (*Runtime) EnterRecordMutex ¶
func (r *Runtime) EnterRecordMutex() func()
EnterRecordMutex locks the process-local record mutex and returns unlock.
type RuntimeOptions ¶
type RuntimeOptions struct {
BasePath string
Component string
Config Config
PrivateFS *platform.PrivateFS
OpenLock func(*platform.PrivateFS, string) (platform.AdvisoryLock, error)
Redactor *Redactor
Reporter FailureReporter
}
RuntimeOptions opens a component-scoped JSONL logging runtime.