class

FileSink

Lines land in a memory buffer and reach the disk from a flusher thread every 200 ms, when the buffer fills, on any Error/Fatal line, on Flush, and from the crash handler's pre-report hook — never with a syscall per line. The old sink wrote std::endl per message, one flush each, which was a measurable share of a Debug frame under the render-init spam. The file is opened shared-read so the crash reporter's tail copy and a tail tool still see it mid-session.

Module
Logging
Header
#include "Logging/Logger.h"
Namespace
Mowo

No thread that logs ever waits on the disk. The flusher opens the file, swaps the buffer out under the lock and writes it with the lock released; an Error line only wakes it. The lock used to be held across fwrite and fflush, and on a disk taking seconds per write (a project on a busy HDD) every logging thread — the render thread included — froze behind it: the owner's 14 s and 19 s "submit" stalls were the render thread waiting to append one line. A disk that takes nothing for long enough costs lines, counted in the file, never a frame.

Constructors

SignatureNameDescription
explicit FileSink(const std::string& filepath, bool append = false, std::functio…FileSink
~FileSink() override~FileSink

Public functions

ReturnsNameDescription
voidWrite
voidFlush
voidCrashFlush
boolIsOpenWaits for the flusher's open attempt.
const std::string&GetFilepath
voidSetWriteStallForTestHolds every disk write of every FileSink this long — a test's stand-in for a disk that takes seconds per write.

Function details

FileSink

C++
explicit FileSink(const std::string& filepath, bool append = false, std::function<void()> afterOpen = {})

~FileSink

C++
~FileSink() override

Write

C++
void Write(const LogMessage& msg) override

Flush

C++
void Flush() override

CrashFlush

C++
void CrashFlush() override

IsOpen

C++
bool IsOpen()

Waits for the flusher's open attempt.

GetFilepath

C++
const std::string& GetFilepath() const

SetWriteStallForTest

C++
static void SetWriteStallForTest(int32_t milliseconds)

Holds every disk write of every FileSink this long — a test's stand-in for a disk that takes seconds per write.

Generated from Logging/Logger.h via logging.json · Oct 27, 2026Version 1.0.0