7 #include "TxEventLogFactory.h"
8 #include "TxEventLogWeb.h"
9 #include "TxEventLogCollector.h"
11 using namespace TxLogging;
14 TxEventLog* TxEventLogFactory::create(
const char *technology)
17 if (technology && (*technology==
'w' || *technology==
'W' ))
19 else if (technology && (*technology==
'c' || *technology==
'C'|| *technology==
'U' || *technology==
'u' ))
54 static void log(
const char *key,
const char *value)
56 using namespace TxLogging;
57 printf(
"\" %s \"=\"%s\"", key, value);
59 const char * ucmCollector =
"ucm";
60 TxEventLog *eventLog = TxEventLogFactory::create(ucmCollector);
63 if(! strcmp(key,
"JobSubmitState")){
65 if(!strcmp(value,
"STAGEIN")){
66 eventLog->setJobSubmitState(TxEventLog::STAGEIN);
67 }
else if(!strcmp(value,
"ACTIVE")){
68 eventLog->setJobSubmitState(TxEventLog::ACTIVE);
69 }
else if(!strcmp(value,
"DONE")){
70 eventLog->setJobSubmitState(TxEventLog::DONE);
75 eventLog->logStart(key, value);
79 int Main(
int argc,
const char *argv[])
82 while (--argc) arg += *(++argv);
85 char errtext[512]={0};
88 const char *regX1 =
"^ *([^ ]+) *= *([^ ]+.*[^ ]*) *$";
89 const char *regX2 =
"^ *-key *([^ ]+) *-value *([^ ]+.*[^ ]*) *$";
90 regcomp(&rgex1,regX1,REG_ICASE | REG_EXTENDED);
91 regcomp(&rgex2,regX2,REG_ICASE | REG_EXTENDED );
92 regmatch_t matchptr [3];
93 size_t nmatch =
sizeof(matchptr)/
sizeof(regmatch_t);
94 if (! (errcode = regexec(&rgex1,arg.c_str(),nmatch,matchptr,0) ) ) {
95 string key = arg.substr(matchptr[1].rm_so, matchptr[1].rm_eo-matchptr[1].rm_so );
96 string value = arg.substr(matchptr[2].rm_so, matchptr[2].rm_eo-matchptr[2].rm_so );
97 log(key.c_str(), value.c_str());
98 }
else if (! regexec(&rgex2,arg.c_str(),nmatch,matchptr,0) ) {
99 string key = arg.substr(matchptr[1].rm_so, matchptr[1].rm_eo-matchptr[1].rm_so );
100 string value = arg.substr(matchptr[2].rm_so, matchptr[2].rm_eo-matchptr[2].rm_so );
101 log(key.c_str(), value.c_str());
103 const char *usage =
" Input format error\n"
107 " ulog -key [key] -value [value]\n"
109 " ulog [key]=[value]\n"
111 printf(
"\n%s: %s\n",arg.c_str(),usage);
121 int TxEventLogFactory::main(
int argc,
const char *argv[])
123 return Main(argc, argv);