#include <Cmessage.hpp>
Public Types | |
enum | verbose_levels { DEBUG_MESSAGES, ALL_MESSAGES, LITTLE_MESSAGES, NO_MESSAGES } |
Public Member Functions | |
void | set_verbose_level (size_t level) |
const size_t | verbose_level () const |
void | operator() (const std::string &message, const int priority_level, int intend=0) |
void | operator() (int intend) |
Static Public Attributes | |
static Cmessage | out |
This class provides an implementation of the imaging2 log message interface. The class defines the static member CMessage::out is declared. Cmessage formats them accordingly and prints them to the standard output.
The user can adjust the verbose level. This function is specific to Cmessage and not part of MessageInterface. Ideally the user includes core/Cmessage.hpp
in as little files as possible and mainly relies on core/MessageInterface.hpp
for displaying log messages.
Here is an example on how Cmessage can be used:
#include <core/Cmessage.hpp> using imaging; int main ( int argc, char **argv ) { // configure Cmessage::cmessage_out to display ALL messages // this function is specific to Cmessage Cmessage::out.set_verbose_level(Cmessage::DEBUG_MESSAGES); // from now on only MessageInterface is required MessageInterface::out("Start program.", MessageInterface::IMPORTANT); // user enters data MessageInterface::out("User entered:", MessageInterface::LESS_IMPORTANT, +1); MessageInterface::out(data, MessageInterface::LESS_IMPORTANT, +1); // check if data is valid MessageInterface::out(+1) MessageInterface::out("Wrong data entered!", MessageInterface::DEBUG_ONLY); MessageInterface::out("User is an idiot!", MessageInterface::DEBUG_ONLY); MessageInterface::out(-1) MessageInterface::out("Finished program.", MessageInterface::IMPORTANT); }
Under the condition that MessageInterface::out is configured to display all messages (including those of type MessageInterface::DEBUG_ONLY) the above code will produce the following result:
Start program. User entered: ...the data... Wrong data entered! User is an idiot! Finished program.
void imaging::Cmessage::set_verbose_level | ( | size_t | level | ) |
Sets the current verbose level of the message object. This is e.g. useful, if the user wants to temporarily increase the verbose level.
const size_t imaging::Cmessage::verbose_level | ( | ) | const [inline] |
Returns the current verbose level.
void imaging::Cmessage::operator() | ( | const std::string & | message, | |
const int | priority_level, | |||
int | intend = 0 | |||
) | [virtual] |
Prints message. The priority and the level of intendation relative to the global intendation are determined by priority_level and intend. The specified intendentation is valid for this message only does not change the global intendation.
Implements imaging::MessageInterface.
void imaging::Cmessage::operator() | ( | int | intend | ) | [virtual] |
Changes the global intendentation by intend.
Implements imaging::MessageInterface.
References imaging::max().
Cmessage imaging::Cmessage::out [static] |
Global log message output object.
Reimplemented from imaging::MessageInterface.