Scyllarus: C++ Hyperspectral Processing Library
Hyperspectral Image Processing Pipeline
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
scyl::logger Class Reference

Logger is used to record messages and other processing details for the scyl library functions and access them during program execution. More...

#include <logger.h>

Public Types

typedef std::pair< std::string,
std::string > 
logitem
 
typedef std::vector< logitemlog
 

Public Member Functions

void set_print_output (bool in)
 Toggle the console output of the Logger on or off. More...
 
void set_bar (bool in)
 Toggle the progress bar in the console on and off (may want to disable if you need higher levels of debugging output) More...
 
int percentage ()
 percentage returns the currently set percentage More...
 
void set_percentage (int in)
 Set the percentage. More...
 
void check_abort ()
 check_abort checks the status of the abort boolean. If it is set to false it does nothing, otherwise it throws an exception. After this function 'successfully' throws an exception, the boolean value must be reset before processing can continue. More...
 
void set_abort (bool in)
 set_abort sets the abort boolean. If set to true, the next time a processing function calls check_abort an exception will be thrown (and processing will exit) More...
 
bool abort () const
 
scyl::PIPELINE_STAGE stage ()
 stage returns the currently set pipeline stage. More...
 
void set_stage (scyl::PIPELINE_STAGE in)
 Set the pipeline stage. More...
 
scyl::logger::log get_logs ()
 get_logs returns the log vector More...
 
scyl::logger::log take_logs ()
 take_logs returns the log vector, and clears the Logger's logs.. More...
 
void save_logs (std::string filename)
 save_logs outputs the Loggers current log list to a file More...
 
template<typename T >
scyl::loggeroperator<< (T const &in)
 Pipe operator for the logger. Used to add logs. More...
 

Static Public Member Functions

static loggeraccess ()
 Logger access function is used to access the logger object. More...
 
static std::string endl ()
 
static std::string timestamp ()
 timestamp returns a string giving the current time, eg: "2013-Jan-01 12:12:12" More...
 

Private Member Functions

 logger ()
 
virtual ~logger ()
 
void add_log (const std::string &timestamp, const std::string &in)
 add_log adds a log to the list of logs More...
 

Private Attributes

std::stringstream m_ss
 
scyl::PIPELINE_STAGE m_stage
 
scyl::logger::log m_log
 
int m_percentage
 
bool m_print
 
bool m_abort
 
bool m_bar
 

Static Private Attributes

static loggerm_instance = 0
 

Detailed Description

Logger is used to record messages and other processing details for the scyl library functions and access them during program execution.

All messages logged to the class are printed by default, though this can be disabled by calling:

scyl::logger::access()->set_print_output(false);

To use the logger, you need go through the access function which returns the static logger instance. To record a log message:

*scyl::logger::access() << "Message: " << 1234 << " more message" << scyl::logger::endl();

To get (and print) the logs from the class, use the get_logs function which returns a log object (a vector of string pairs (Timestamp, Message))

scyl::logger::log logs = scyl::logger::access()->get_logs();
for (scyl::logger::log::iterator it = logs.begin(); it != logs.end(); it++)
{
    std::cout << it->first << " " << it->second << std::endl;

Member Typedef Documentation

typedef std::vector<logitem> scyl::logger::log
typedef std::pair<std::string, std::string> scyl::logger::logitem

Constructor & Destructor Documentation

scyl::logger::logger ( )
private

Logger constructor (private)

scyl::logger::~logger ( )
privatevirtual

Logger destructor (private)

Member Function Documentation

bool scyl::logger::abort ( ) const

Get abort boolean value.

scyl::logger * scyl::logger::access ( )
static

Logger access function is used to access the logger object.

Anytime you wish to use the logger, from anywhere in the code, just call

scyl::logger::access()

which will return the logger instance for use, eg:

*scyl::logger::access() << "Message" << scyl::logger::endl();
scyl::logger::access()->set_percentage(55);
Returns
The logger instance.
Examples:
cli_pipeline.cpp.
void scyl::logger::add_log ( const std::string &  timestamp,
const std::string &  in 
)
private

add_log adds a log to the list of logs

This function is intended for use by the logger class itself. Preferably use the stream operator (<<) to add logs to the log.

Parameters
timestampString timestamp for this log item
inString message fo this log item
void scyl::logger::check_abort ( )

check_abort checks the status of the abort boolean. If it is set to false it does nothing, otherwise it throws an exception. After this function 'successfully' throws an exception, the boolean value must be reset before processing can continue.

Exceptions
Exceptionabort.
static std::string scyl::logger::endl ( )
inlinestatic
scyl::logger::log scyl::logger::get_logs ( )

get_logs returns the log vector

Returns
template<typename T >
scyl::logger& scyl::logger::operator<< ( T const &  in)
inline

Pipe operator for the logger. Used to add logs.

Parameters
in
Returns
int scyl::logger::percentage ( )

percentage returns the currently set percentage

Returns
integer percentage value
void scyl::logger::save_logs ( std::string  filename)

save_logs outputs the Loggers current log list to a file

Parameters
filenamePath and filename to write the logs to
Examples:
cli_pipeline.cpp.
void scyl::logger::set_abort ( bool  in)

set_abort sets the abort boolean. If set to true, the next time a processing function calls check_abort an exception will be thrown (and processing will exit)

Parameters
inValue to set abort boolean to
void scyl::logger::set_bar ( bool  in)

Toggle the progress bar in the console on and off (may want to disable if you need higher levels of debugging output)

Parameters
intrue = bar on
void scyl::logger::set_percentage ( int  in)

Set the percentage.

Parameters
inpercentage
void scyl::logger::set_print_output ( bool  in)

Toggle the console output of the Logger on or off.

Parameters
intrue = output on
void scyl::logger::set_stage ( scyl::PIPELINE_STAGE  in)

Set the pipeline stage.

Parameters
incurrent pipeline stage.
scyl::PIPELINE_STAGE scyl::logger::stage ( )

stage returns the currently set pipeline stage.

Returns
Pipeline stage (enum)
scyl::logger::log scyl::logger::take_logs ( )

take_logs returns the log vector, and clears the Logger's logs..

Returns
std::string scyl::logger::timestamp ( )
static

timestamp returns a string giving the current time, eg: "2013-Jan-01 12:12:12"

Returns
timestamp.

Member Data Documentation

bool scyl::logger::m_abort
private
bool scyl::logger::m_bar
private
scyl::logger * scyl::logger::m_instance = 0
staticprivate
scyl::logger::log scyl::logger::m_log
private
int scyl::logger::m_percentage
private
bool scyl::logger::m_print
private
std::stringstream scyl::logger::m_ss
private
scyl::PIPELINE_STAGE scyl::logger::m_stage
private

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