21{
23
24 string message_logger;
25 bool use_cout;
26 bool use_cin;
27 bool off;
29
30 try {
31
32 JParser<> zap(
"Example program to test message logging.");
33
34 zap[
'M'] =
make_field(message_logger) =
"localhost";
39
40 zap(argc, argv);
41 }
42 catch(const exception &error) {
43 FATAL(error.what() << endl);
44 }
45
47
48
50
51 if (use_cout)
53 else
55
57
58 if (off) {
59 logger.setLevel(JMessageLogger::OFF);
60 }
61
62 if (!use_cin) {
63
64 logger.debug ("hello world");
65 logger.warning("hello world");
66 logger.error ("hello world");
67 logger.notice ("hello world");
68 logger.status ("hello world");
69
70 JErrorStream(logger) <<
"hello" <<
' ' <<
"world" <<
' ' << hex << 15;
71
72 } else {
73
74 for (string buffer; ; ) {
75
76 cout << "> " << flush;
77
79
80 if (buffer != "")
81 logger.notice(buffer);
82 else
83 break;
84 }
85 }
86}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Message logging based on ControlHost.
Interface for logging messages.
Message logging based on std::ostream.
Utility class to parse command line options.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).