1 #include "TxEventLog.h"
2 #include "TxEventLogFactory.h"
11 std::cout <<
"\nUSAGE:"
13 <<
"\n -r/--requester <requester name> : required"
14 <<
"\n -j/--brokerjobid <broker job id> : required"
15 <<
"\n -t/--brokertaskid <broker task id> : required"
16 <<
"\n -k/--key <message key> : required"
17 <<
"\n -v/--value <message value> : required"
18 <<
"\n -l/--level <event level> : optional"
19 <<
"\n -c/--context <event context> : optional"
20 << std::endl << std::endl;
23 int getOpts (
int argc,
char** argv, std::string& requester,
24 std::string& brokerJobID, std::string& brokerTaskID,
25 std::string& key, std::string& value,
26 std::string& context, std::string& level)
28 static const char *optString =
"r:j:t:c:l:s:k:v:h?";
29 static struct option longOpts [] = {
30 {
"requester", required_argument, NULL,
'r'},
31 {
"brokerjobid", required_argument, NULL,
'j'},
32 {
"brokertaskid", required_argument, NULL,
't'},
33 {
"key", required_argument, NULL,
'k'},
34 {
"value", required_argument, NULL,
'v'},
35 {
"context", required_argument, NULL,
'c'},
36 {
"level", required_argument, NULL,
'l'},
37 {
"help", no_argument, NULL,
'h'}
41 int opt = getopt_long (argc, argv, optString, longOpts, &longIndex);
47 bool rOpt =
false, jOpt =
false, tOpt =
false, kOpt =
false, vOpt =
false;
62 brokerTaskID = optarg;
91 opt = getopt_long (argc, argv, optString, longOpts, &longIndex);
94 if (!rOpt || !jOpt || !tOpt || !kOpt || !vOpt) {
102 TxLogging::TxEventLog::Level getLevel (
const std::string& level) {
103 int intLevel = std::atoi (level.c_str ());
106 return TxLogging::TxEventLog::LEVEL_TRACE;
109 return TxLogging::TxEventLog::LEVEL_DEBUG;
112 return TxLogging::TxEventLog::LEVEL_INFO;
115 return TxLogging::TxEventLog::LEVEL_NOTICE;
118 return TxLogging::TxEventLog::LEVEL_WARNING;
121 return TxLogging::TxEventLog::LEVEL_ERROR;
124 return TxLogging::TxEventLog::LEVEL_CRITICAL;
127 return TxLogging::TxEventLog::LEVEL_ALERT;
130 return TxLogging::TxEventLog::LEVEL_FATAL;
133 return TxLogging::TxEventLog::LEVEL_UNKNOWN;
137 int main (
int argc,
char** argv) {
138 std::string requester =
"",
146 if (getOpts (argc, argv, requester,
147 brokerJobID, brokerTaskID,
154 int intBJobID = std::atoi (brokerJobID.c_str ());
159 getLevel (level), TxLogging::TxEventLog::STATUS,
virtual void setBrokerTaskID(const std::string &brokerTaskID)=0
virtual void setRequesterName(const std::string &requester)=0
virtual void setBrokerJobID(int brokerJobID)=0
virtual void logEvent(const std::string &logMsg, Level level=LEVEL_INFO, Stage stage=STATUS, const std::string &msgContext=TxUCMConstants::defaultContext)=0