Temporary scope-based enable/disable zone for logging streams. More...
#include <enablesZone.hpp>
Public Member Functions | |
| enablesZone (nbool newVal) | |
| Constructs an enablesZone and immediately sets all logging streams to the specified enable state, without capturing their previous states. | |
| const enables & | getPrev () const |
| me & | setPrev () |
| Captures the current enable states of all streams as the new "previous" state. This state will be restored when the enablesZone object is destroyed. | |
| me & | rel () |
| Manually releases the enablesZone, preventing restoration of stream states on destruction. | |
| me & | setEnable (nbool newVal) |
| Sets the enable state for all streams managed by the logger. | |
| me & | setEnable (const std::string &streamName, nbool newVal) |
| Sets the enable state for a specific named stream. | |
Temporary scope-based enable/disable zone for logging streams.
The logger class has multiple stream objects, and you can control output destinations by enabling or disabling specific streams. However, it's very common to need to control streams only within a specific code block or function, then restore the original state when leaving that block.
enablesZone is designed for this use case. Implemented using the RAII idiom, it records the enable state of streams upon object creation, then restores each stream's enable status to its initial state when the enablesZone is destroyed.
Typical usage pattern:
| by::enablesZone::enablesZone | ( | nbool | newVal | ) |
Constructs an enablesZone and immediately sets all logging streams to the specified enable state, without capturing their previous states.
| newVal | The new enable state for all streams (true for enabled, false for disabled). |
| me & by::enablesZone::rel | ( | ) |
Manually releases the enablesZone, preventing restoration of stream states on destruction.
Sets the enable state for a specific named stream.
| streamName | The name of the stream to modify. |
| newVal | The new enable state (true for enabled, false for disabled). |
Sets the enable state for all streams managed by the logger.
| newVal | The new enable state (true for enabled, false for disabled). |
| me & by::enablesZone::setPrev | ( | ) |
Captures the current enable states of all streams as the new "previous" state. This state will be restored when the enablesZone object is destroyed.