Skip to main content

LogArchiver

A static class in TavernLib, TavernLib.Debugging.

Moves the game's unity-log.csv into a numbered file in an Archives folder next to it, keeping 20. TavernLib runs it on servers it manages (not with /launcherauth).

Fields​

3 private and internal fields
MemberWhat it is
private const int MaxArchiveFilesMost archived logs kept, 20; the oldest are deleted first.
private const long SizeThresholdBytesLog size at which ShouldAutoArchive is true, 10,000,000 bytes.
private const string TargetNameThe NLog target name assumed for the Unity log, "unity-log".

Methods​

MemberWhat it is
static string ArchiveLogNow()Moves the log now, briefly clearing NLog's configuration to free the file. Returns the archive's path, or null if nothing was moved.
static bool ShouldAutoArchive()True when unity-log.csv is 10 MB or more.
3 private and internal methods
MemberWhat it is
private static FileTarget FindUnityLogTarget()Finds the NLog file target for the Unity log by name, or by a file name ending in unity-log.csv.
private static string RenderFilePath(FileTarget target)Returns the file path a target writes to, or null if it can't be worked out.
private static int? TryParseSequenceNumber(string path, string stem, string ext)Reads the sequence number from an archived log's file name, or null if it doesn't match.