ADUL
Collection of reusable C++ utilities
Loading...
Searching...
No Matches
adul::logs::Logger Class Reference

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Logger()

adul::logs::Logger::Logger ( )

Member Function Documentation

◆ activate()

void adul::logs::Logger::activate ( )

activates the timer

sets the "flagActive" to true

◆ addStream()

void adul::logs::Logger::addStream ( std::basic_ostream< char > & p_stream)

◆ clearStreams()

void adul::logs::Logger::clearStreams ( )

◆ deactivate()

void adul::logs::Logger::deactivate ( )

deactivates the timer

sets the "flagActive" to false

◆ isActive()

bool adul::logs::Logger::isActive ( ) const

◆ isReady()

bool adul::logs::Logger::isReady ( ) const

◆ push()

template<typename T >
void adul::logs::Logger::push ( const T & message) 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

Parameters
messageis message to be pushed in all the streams
See also
adul::exceptions::Message "Message exception class"
start "start() method"
stop "stop() method"
activate "activate() method"
deactivate "deactivate() method"

◆ start()

void adul::logs::Logger::start ( )

initializes the logger

sets the "flagReady" to true and starts clock since initialization

◆ stop()

void adul::logs::Logger::stop ( )

stops the logger

sets "flagReady" to false and stops the timer;

Member Data Documentation

◆ clock

time::Clock adul::logs::Logger::clock
protected

◆ flagActive

bool adul::logs::Logger::flagActive = false
protected

◆ flagReady

bool adul::logs::Logger::flagReady = false
protected

◆ streams

std::vector<std::reference_wrapper<std::ostream> > adul::logs::Logger::streams
protected

The documentation for this class was generated from the following file: