Documentation
¶
Overview ¶
Package logfile provides Ether's on-disk logs: a size-rotated log file (stderr is discarded under a Windows service and unrotated under launchd) and the crash log that receives fatal runtime traces.
Index ¶
Constants ¶
const ( CrashLogName = "crash.log" // DefaultCrashMaxSize caps crash.log; larger logs are moved to // crash.log.1 at startup. DefaultCrashMaxSize int64 = 5 << 20 )
Crash log file names inside the logs directory.
const ( DefaultMaxSize int64 = 10 << 20 // rotate at 10 MiB DefaultKeep = 5 // ether.log.1 … ether.log.5 )
Defaults for the main log file.
const MainLogName = "ether.log"
MainLogName is the main log file inside the logs directory.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CrashLog ¶
type CrashLog struct {
// File is open for appending; hand it to debug.SetCrashOutput (which
// duplicates the descriptor) and then close it.
File *os.File
// Path is the crash log path.
Path string
// Changed reports that the crash log was written since the previous
// start, i.e. the previous run died with a fatal error.
Changed bool
}
CrashLog is the result of PrepareCrashLog.
func PrepareCrashLog ¶
PrepareCrashLog opens <dir>/crash.log for appending, rotating it to crash.log.1 first when it exceeds maxSize (<= 0: DefaultCrashMaxSize), and reports whether it changed since the previous call (tracked by a marker file touched on every call).
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is a concurrency-safe io.Writer that appends to a file and rotates it by size: path -> path.1 -> … -> path.<keep>, dropping the oldest. A failed open or write closes the file and the next Write reopens it, so a transient error (disk full, file removed) does not disable logging for the rest of the process.
func Open ¶
Open creates the directory if needed and opens path for appending. maxSize <= 0 uses DefaultMaxSize; keep < 0 uses DefaultKeep (0 keeps no rotated files: the log is truncated at maxSize).