#include #include #include #include "JLogger/JStreamLogger.hh" #include "JLogger/JControlHostLogger.hh" #include "JLogger/JMessageLogger.hh" #include "JLogger/JMessageStream.hh" #include "JLogger/JMessageScheduler.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test message scheduling. * \author mdejong */ int main(int argc, char* argv[]) { using namespace std; string message_logger; bool use_cout; int log_s; int numberOfMessages; int debug; try { JParser<> zap("Example program to test message scheduling."); zap['M'] = make_field(message_logger) = "localhost"; zap['c'] = make_field(use_cout); zap['T'] = make_field(log_s); zap['n'] = make_field(numberOfMessages); 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); JMessageScheduler scheduler(logger, JTimekeeper(log_s * 1000000)); scheduler.setCredit(3); for (int i = 0; i != numberOfMessages; ++i) { cout << "sleep [s] " << i * log_s << endl; usleep(i * log_s * 1000000); for (int i = 0; i != numberOfMessages; ++i) { JErrorStream(scheduler) << i; } } }