#include #include #include #include "JLogger/JStreamLogger.hh" #include "JLogger/JControlHostLogger.hh" #include "JLogger/JMessageLogger.hh" #include "JLogger/JMessageStream.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test message logging. * \author mdejong */ int main(int argc, char* argv[]) { using namespace std; string message_logger; bool use_cout; bool use_cin; bool off; int debug; try { JParser<> zap("Example program to test message logging."); zap['M'] = make_field(message_logger) = "localhost"; zap['c'] = make_field(use_cout); zap['C'] = make_field(use_cin); zap['x'] = make_field(off); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; JLogger* out = NULL; if (use_cout) out = new JStreamLogger(cout); else out = new JControlHostLogger(message_logger); JMessageLogger logger(out, argv[0], debug); if (off) { logger.setLevel(JMessageLogger::OFF); } if (!use_cin) { logger.debug ("hello world"); logger.warning("hello world"); logger.error ("hello world"); logger.notice ("hello world"); logger.status ("hello world"); JErrorStream(logger) << "hello" << ' ' << "world" << ' ' << hex << 15; } else { for (string buffer; ; ) { cout << "> " << flush; getline(cin, buffer); if (buffer != "") logger.notice(buffer); else break; } } }