Game Audio Module
A C++ audio system using miniaudio with Python bindings
Loading...
Searching...
No Matches
logging.h
Go to the documentation of this file.
1#pragma once
2
8#include <string>
9#include <sstream>
10
11namespace audio {
12
18enum class LogLevel {
19 Off = 0,
20 Error = 1,
21 Warn = 2,
22 Info = 3,
23 Debug = 4,
24};
25
31class Logger {
32public:
36 static void SetLevel(LogLevel level);
37
41 static LogLevel GetLevel();
42
46 static bool IsEnabled(LogLevel level);
47
51 static void Log(LogLevel level, const std::string& message);
52};
53
60#define AUDIO_LOG(level, stream_expr) \
61 do { \
62 if (audio::Logger::IsEnabled(level)) { \
63 std::ostringstream _audio_log_stream; \
64 _audio_log_stream << stream_expr; \
65 audio::Logger::Log(level, _audio_log_stream.str());\
66 } \
67 } while (0)
68
69} // namespace audio
Global logger for the audio module (runtime level control).
Definition logging.h:31
static void SetLevel(LogLevel level)
Set the global log level.
Definition logging.cpp:11
static LogLevel GetLevel()
Get the current log level.
Definition logging.cpp:15
static void Log(LogLevel level, const std::string &message)
Emit a log message at the specified level.
Definition logging.cpp:23
static bool IsEnabled(LogLevel level)
Check if a log level is enabled.
Definition logging.cpp:19
Definition audio_group.cpp:7
LogLevel
Log severity levels for audio diagnostics.
Definition logging.h:18
@ Info
High-level lifecycle and state transitions.
@ Warn
Recoverable or unusual conditions.
@ Error
Fatal failures and unrecoverable errors.
@ Debug
Detailed diagnostics (noisy)
@ Off
Disable all logging.