ADUL
Collection of reusable C++ utilities
|
This is "Logger" class. More...
#include <logs.hpp>
Public Member Functions | |
Logger () | |
void | addStream (std::basic_ostream< char > &p_stream) |
void | clearStreams () |
void | start () |
initializes the logger | |
void | stop () |
stops the logger | |
bool | isReady () const |
void | activate () |
activates the timer | |
void | deactivate () |
deactivates the timer | |
bool | isActive () const |
template<typename T > | |
void | push (const T &message) const |
pushes message to all the logger streams | |
Protected Attributes | |
time::Clock | clock |
std::vector< std::reference_wrapper< std::ostream > > | streams |
bool | flagReady = false |
bool | flagActive = false |
This is "Logger" class.
It basically prints the messages to all the streams in "streams" vector if the object is "flagReady" and "flagActive"
isReady represents the state if the logger is initialized
isActive represents the state if logger should work right now.
isActive = false prevents logger::push method from working and doesn't throw any exceptions
Both "flagActive" and "flagReady" are false by default and must be modified via methods activate and start correspondingly
adul::logs::Logger::Logger | ( | ) |
void adul::logs::Logger::activate | ( | ) |
activates the timer
sets the "flagActive" to true
void adul::logs::Logger::addStream | ( | std::basic_ostream< char > & | p_stream | ) |
void adul::logs::Logger::clearStreams | ( | ) |
void adul::logs::Logger::deactivate | ( | ) |
deactivates the timer
sets the "flagActive" to false
bool adul::logs::Logger::isActive | ( | ) | const |
bool adul::logs::Logger::isReady | ( | ) | const |
|
inline |
pushes message to all the logger streams
if "flagActive" is false doesn't do anything
if "flagReady" is true runs properly, otherwise throws an adul::exceptions::message
before every message it prints the time since last usage of start() method in milliseconds
message | is message to be pushed in all the streams |
void adul::logs::Logger::start | ( | ) |
initializes the logger
sets the "flagReady" to true and starts clock since initialization
void adul::logs::Logger::stop | ( | ) |
stops the logger
sets "flagReady" to false and stops the timer;
|
protected |
|
protected |
|
protected |
|
protected |