Jpp
18.0.0-rc.4
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLogger
JMessageLogger.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLogger/JStreamLogger.hh
"
6
#include "
JLogger/JControlHostLogger.hh
"
7
#include "
JLogger/JMessageLogger.hh
"
8
#include "
JLogger/JMessageStream.hh
"
9
10
#include "
Jeep/JParser.hh
"
11
#include "
Jeep/JMessage.hh
"
12
13
14
/**
15
* \file
16
*
17
* Example program to test message logging.
18
* \author mdejong
19
*/
20
int
main
(
int
argc,
char
* argv[])
21
{
22
using namespace
std;
23
24
string
message_logger;
25
bool
use_cout;
26
bool
use_cin;
27
bool
off;
28
int
debug
;
29
30
try
{
31
32
JParser<>
zap(
"Example program to test message logging."
);
33
34
zap[
'M'
] =
make_field
(message_logger) =
"localhost"
;
35
zap[
'c'
] =
make_field
(use_cout);
36
zap[
'C'
] =
make_field
(use_cin);
37
zap[
'x'
] =
make_field
(off);
38
zap[
'd'
] =
make_field
(
debug
) = 3;
39
40
zap(argc, argv);
41
}
42
catch
(
const
exception &error) {
43
FATAL
(error.what() << endl);
44
}
45
46
using namespace
JPP;
47
48
49
JLogger* out = NULL;
50
51
if
(use_cout)
52
out =
new
JStreamLogger(cout);
53
else
54
out =
new
JControlHostLogger(message_logger);
55
56
JMessageLogger logger(out, argv[0],
debug
);
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
78
getline
(cin, buffer);
79
80
if
(buffer !=
""
)
81
logger.notice(buffer);
82
else
83
break
;
84
}
85
}
86
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JStreamLogger.hh
JMessageStream.hh
Message reporting compatible with STL output stream operations.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
JControlHostLogger.hh
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition:
JString.hh:478
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JMessageLogger.hh
General purpose message reporting.
JParser.hh
Utility class to parse command line options.
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5