Jpp
18.2.0
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
JMessageScheduler.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
#include "
JLogger/JMessageScheduler.hh
"
10
11
#include "
Jeep/JParser.hh
"
12
#include "
Jeep/JMessage.hh
"
13
14
15
/**
16
* \file
17
*
18
* Example program to test message scheduling.
19
* \author mdejong
20
*/
21
int
main
(
int
argc,
char
* argv[])
22
{
23
using namespace
std;
24
25
string
message_logger;
26
bool
use_cout;
27
int
log_s;
28
int
numberOfMessages;
29
int
debug
;
30
31
try
{
32
33
JParser<>
zap(
"Example program to test message scheduling."
);
34
35
zap[
'M'
] =
make_field
(message_logger) =
"localhost"
;
36
zap[
'c'
] =
make_field
(use_cout);
37
zap[
'T'
] =
make_field
(log_s);
38
zap[
'n'
] =
make_field
(numberOfMessages);
39
zap[
'd'
] =
make_field
(
debug
) = 3;
40
41
zap(argc, argv);
42
}
43
catch
(
const
exception &error) {
44
FATAL
(error.what() << endl);
45
}
46
47
using namespace
JPP;
48
49
50
JLogger* out = NULL;
51
52
if
(use_cout)
53
out =
new
JStreamLogger(cout);
54
else
55
out =
new
JControlHostLogger(message_logger);
56
57
JMessageLogger logger(out, argv[0],
debug
);
58
JMessageScheduler scheduler(logger, JTimekeeper(log_s * 1000000));
59
60
scheduler.setCredit(3);
61
62
for
(
int
i
= 0;
i
!= numberOfMessages; ++
i
) {
63
64
cout <<
"sleep [s] "
<<
i
* log_s << endl;
65
66
usleep(
i
* log_s * 1000000);
67
68
for
(
int
i
= 0;
i
!= numberOfMessages; ++
i
) {
69
JErrorStream(scheduler) <<
i
;
70
}
71
}
72
}
JMessageScheduler.hh
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.
i
then rm i
Definition:
JEvtReweightMupageParameterScan.sh:309
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
JControlHostLogger.hh
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