Logger
- Module
- Logging
- Header
#include "Logging/Logger.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
Logger(const Logger&) = delete | Logger |
Public functions
| Returns | Name | Description |
|---|---|---|
Logger& | Get | |
Logger& | operator= | |
void | AddSink | |
void | RemoveSink | |
void | ClearSinks | |
void | SetMinLevel | |
LogLevel | GetMinLevel | |
void | Log | |
void | SetFloodGuard | The flood guard: a category that writes more than linesPerSecond lines in each of seconds consecutive seconds gets one warning naming its busiest call site. |
uint32_t | GetFloodGuardLinesPerSecond | |
void | ResetFloodGuard | Forgets every category's window and warning, so a test starts clean. |
void | LogFormat | |
void | Flush | |
void | CrashFlush | What the crash handler runs before it copies the log tail: best effort, no allocation, and never a wait on a lock the crashing thread itself may hold. |
void | CrashFlushHook | |
std::filesystem::path | ResolveLogsDir | Where the file sink writes: <project>/Saved/Logs when a project is open, else <state root>/<Product>/Saved/Logs (Launcher, headless self-tests, packaged games with no writable project). |
void | Initialize | Opens the console + file sinks and rotates old Mowo_*.log files out. |
void | PruneOldLogs | Deletes the oldest Mowo_*.log / mowo_*.log files beyond keep. |
const std::string& | GetLogFilePath | Absolute path of the file sink Initialize opened; empty without one. |
void | Shutdown |
Function details
Logger
Logger(const Logger&) = deleteGet
static Logger& Get()operator=
Logger& operator=(const Logger&) = deleteAddSink
void AddSink(Ref<LogSink> sink)RemoveSink
void RemoveSink(const Ref<LogSink>& sink)ClearSinks
void ClearSinks()SetMinLevel
void SetMinLevel(LogLevel level)GetMinLevel
LogLevel GetMinLevel() constLog
void Log(LogLevel level, const std::string& category, const std::string& message, const char* file = nullptr, int line = 0)SetFloodGuard
void SetFloodGuard(uint32_t linesPerSecond, uint32_t seconds)The flood guard: a category that writes more than linesPerSecond lines in each of seconds consecutive seconds gets one warning naming its busiest call site. Only call sites with a source file are counted, so a release build (which compiles none in) pays nothing. 0 turns it off.
GetFloodGuardLinesPerSecond
uint32_t GetFloodGuardLinesPerSecond() constResetFloodGuard
void ResetFloodGuard()Forgets every category's window and warning, so a test starts clean.
LogFormat
void LogFormat(LogLevel level, const std::string& category, const char* file, int line, const char* fmt, ...)Flush
void Flush()CrashFlush
void CrashFlush()What the crash handler runs before it copies the log tail: best effort, no allocation, and never a wait on a lock the crashing thread itself may hold.
CrashFlushHook
static void CrashFlushHook()ResolveLogsDir
static std::filesystem::path ResolveLogsDir()Where the file sink writes: <project>/Saved/Logs when a project is open, else <state root>/<Product>/Saved/Logs (Launcher, headless self-tests, packaged games with no writable project).
Initialize
void Initialize()Opens the console + file sinks and rotates old Mowo_*.log files out. Release builds keep both sinks OFF and the threshold at Warning unless -log is on the command line or the game's Config sets logging.enabled=true (the bUseLoggingInShipping model).
PruneOldLogs
static void PruneOldLogs(const std::filesystem::path& logsDir, size_t keep)Deletes the oldest Mowo_*.log / mowo_*.log files beyond keep.
GetLogFilePath
const std::string& GetLogFilePath() constAbsolute path of the file sink Initialize opened; empty without one.
Shutdown
void Shutdown()