Class FileLogSink¶
Namespace: Apogee.Core.Logging
Assembly: Apogee.Core.dll
Writes each entry as a line of a file that is this run's own: <yyyyMMdd-HHmmss>-<pid>.log (UTC) in a folder that keeps the newest few. The file is flushed after every line, so
that a crash keeps the last ones. Next to it, a .running marker (the process id, when it started and the log's name) lives until
public sealed class FileLogSink : ILogSink, IDisposable
Inheritance¶
Implements¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors¶
FileLogSink(string, string, int, long)¶
Opens a new log file in directory (made if it is missing) and removes the oldest ones, so that keepFiles remain with the new one.
public FileLogSink(string directory, string runName, int keepFiles = 10, long maxBytes = 67108864)
Parameters¶
directory string
runName string
Named in the first line of the file, with the engine version, the OS and the command line.
keepFiles int
maxBytes long
The size after which the file gets one last line and nothing more.
Fields¶
LogExtension¶
The extension of a log file.
public const string LogExtension = ".log"
Field Value¶
MarkerExtension¶
The extension of the marker of a run that has not ended.
public const string MarkerExtension = ".running"
Field Value¶
Properties¶
IsActive¶
False once the file could not be opened or written: nothing is logged any more.
public bool IsActive { get; }
Property Value¶
Path¶
The log file; null when the sink could not open one.
public string? Path { get; }
Property Value¶
Methods¶
Dispose()¶
Writes the last line of the run, closes the file and removes the marker. Safe to call again.
public void Dispose()
Write(in LogEntry)¶
public void Write(in LogEntry entry)
Parameters¶
entry LogEntry