|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
RAII helper that swaps the global logger and level for the lifetime of the object, and restores them in the destructor. More...
#include <logger.hpp>
Public Member Functions | |
| ScopedLoggerOverride () | |
| Snapshots the current sink + level so they can be restored. | |
| ScopedLoggerOverride (std::function< void(LogLevel, std::string_view)> sink, LogLevel level=LogLevel::debug) | |
Installs sink and level; saves whatever was there before. | |
| ~ScopedLoggerOverride () | |
| Restores the saved sink and level. | |
| ScopedLoggerOverride (const ScopedLoggerOverride &)=delete | |
| ScopedLoggerOverride & | operator= (const ScopedLoggerOverride &)=delete |
| ScopedLoggerOverride (ScopedLoggerOverride &&)=delete | |
| ScopedLoggerOverride & | operator= (ScopedLoggerOverride &&)=delete |
RAII helper that swaps the global logger and level for the lifetime of the object, and restores them in the destructor.
Designed for tests that want to capture log output without leaking the custom sink into other tests. Thread-safe construction and destruction — the global mutex is acquired briefly during each.
Definition at line 279 of file logger.hpp.
|
inline |
Snapshots the current sink + level so they can be restored.
Use this when test code will install its own sink mid-test via setLogger() / setLogLevel() and just wants automatic restoration.
Definition at line 285 of file logger.hpp.
|
inlineexplicit |
Installs sink and level; saves whatever was there before.
| sink | New logger sink. Pass a no-op lambda to suppress output entirely. |
| level | New minimum level. Defaults to debug so every message reaches sink. |
Definition at line 304 of file logger.hpp.
|
inline |
Restores the saved sink and level.
Definition at line 318 of file logger.hpp.