Scyllarus: C++ Hyperspectral Processing Library
Hyperspectral Image Processing Pipeline
|
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< logitem > | log |
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::logger & | operator<< (T const &in) |
Pipe operator for the logger. Used to add logs. More... | |
Static Public Member Functions | |
static logger * | access () |
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 ×tamp, 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 logger * | m_instance = 0 |
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;
typedef std::vector<logitem> scyl::logger::log |
typedef std::pair<std::string, std::string> scyl::logger::logitem |
|
private |
Logger constructor (private)
|
privatevirtual |
Logger destructor (private)
bool scyl::logger::abort | ( | ) | const |
Get abort boolean value.
|
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);
|
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.
timestamp | String timestamp for this log item |
in | String 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.
Exception | abort. |
|
inlinestatic |
scyl::logger::log scyl::logger::get_logs | ( | ) |
get_logs returns the log vector
|
inline |
Pipe operator for the logger. Used to add logs.
in |
int scyl::logger::percentage | ( | ) |
percentage returns the currently set percentage
void scyl::logger::save_logs | ( | std::string | filename | ) |
save_logs outputs the Loggers current log list to a file
filename | Path and filename to write the logs to |
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)
in | Value 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)
in | true = bar on |
void scyl::logger::set_percentage | ( | int | in | ) |
Set the percentage.
in | percentage |
void scyl::logger::set_print_output | ( | bool | in | ) |
Toggle the console output of the Logger on or off.
in | true = output on |
void scyl::logger::set_stage | ( | scyl::PIPELINE_STAGE | in | ) |
Set the pipeline stage.
in | current pipeline stage. |
scyl::PIPELINE_STAGE scyl::logger::stage | ( | ) |
stage returns the currently set pipeline stage.
scyl::logger::log scyl::logger::take_logs | ( | ) |
take_logs returns the log vector, and clears the Logger's logs..
|
static |
timestamp returns a string giving the current time, eg: "2013-Jan-01 12:12:12"
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |