StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TxEventLog.h
1 /*
2  * @file TxEventLog.h
3  * @author Roopa Pundaleeka
4  *
5  * @(#)cpp/api:$Id: TxEventLog.h,v 1.7 2010/09/17 19:34:54 fine Exp $
6  *
7  * TxEventLog provides an interface for applications so that they can write
8  * event information into a CEDPS formated file.
9  */
10 
11 #ifndef TX_EVENT_LOG_H
12 #define TX_EVENT_LOG_H
13 
14 #include <string>
15 
16 #include "TxUCMConstants.h"
17 
18 namespace TxLogging {
19 class StUcmTasks;
20 class StUcmJobs;
21 class StUcmEvents;
22 class StRecord;
23 
28  class TxEventLog {
29 
30  public:
31  enum Stage {
32  START = 1,
33  STATUS = 2,
34  END = 3
35  };
36 
37  enum Level {
38  LEVEL_UNKNOWN = 0,
39  LEVEL_TRACE = 1,
40  LEVEL_DEBUG = 2,
41  LEVEL_INFO = 3,
42  LEVEL_NOTICE = 4,
43  LEVEL_WARNING = 5,
44  LEVEL_ERROR = 6,
45  LEVEL_CRITICAL = 7,
46  LEVEL_ALERT = 8,
47  LEVEL_FATAL = 9,
48  TOTAL_LEVELS
49  };
50 
51  enum State {
52  UNKNOWN = 0,
53  UNSUBMITTED = 1,
54  STAGEIN = 2,
55  PENDING = 3,
56  ACTIVE = 4,
57  SUSPENDED = 5,
58  STAGEOUT = 6,
59  CLEANUP = 7,
60  DONE = 8,
61  FAILED = 9,
62  TOTAL_STATES
63  };
64 
65 protected:
71  TxEventLog ();
72  virtual void writeDown(const std::string& message)=0;
73 public:
74 
80  virtual ~TxEventLog ();
81 
82  virtual void writeDown(const char *message);
91  virtual void setEnvBrokerTaskID (const std::string& envBrokerTaskID)=0;
92  void setEnvBrokerTaskID (const char *envBrokerTaskID);
93 
102  virtual void setEnvBrokerJobID (const std::string& envBrokerJobID)=0;
103  void setEnvBrokerJobID (const char *envBrokerJobID);
104 
112  virtual void setBrokerTaskID (const std::string& brokerTaskID)=0;
113  void setBrokerTaskID (const char *brokerTaskID);
114 
122  virtual void setBrokerJobID (int brokerJobID)=0;
123 
130  virtual void setRequesterName (const std::string& requester)=0;
131  void setRequesterName (const char *requester);
132 
138  virtual void setContext (const std::string& context)=0;
139  void setContext (const char *context);
140 
145  virtual void logStart (const std::string& key, const std::string& value)=0;
146  void logStart (const char *key = TxUCMConstants::appStart,
147  const char *value = "application started");
148 
156  virtual void logJobSubmitLocation (const std::string& url)=0;
157  void logJobSubmitLocation (const char *url);
158  virtual void setJobSubmitLocation (const std::string& url)=0;
159  void setJobSubmitLocation (const char *url);
160 
169  virtual void logJobAttribute (const std::string& key, const std::string& value)=0;
170  void logJobAttribute (const char *key, const char *value);
178  virtual void logTask (unsigned int size=1)=0;
179 
191  virtual void logTask (const std::string& taskAttributes)=0;
192  void logTask (const char *taskAttributes);
199  virtual void logJobSubmitState (State state)=0;
200  virtual void setJobSubmitState (State state)=0;
201 
209  virtual void logJobSubmitID (const std::string& ID)=0;
210  void logJobSubmitID (const char *ID);
211  virtual void setJobSubmitID (const std::string& ID)=0;
212  void setJobSubmitID (const char *ID);
213 
224  virtual void logEvent (const std::string& logMsg,
225  Level level = LEVEL_INFO,
226  Stage stage = STATUS,
227  const std::string& msgContext = TxUCMConstants::defaultContext)=0;
228 
229  void logEvent (const char *logMsg,
230  Level level = LEVEL_INFO,
231  Stage stage = STATUS,
232  const char *msgContext = TxUCMConstants::defaultContext);
233 
245  virtual void logEvent (const std::string& userKey,
246  const std::string& userValue,
247  Level level = LEVEL_INFO,
248  Stage stage = STATUS,
249  const std::string& msgContext = TxUCMConstants::defaultContext)=0;
250  void logEvent (const char *userKey,
251  const char *userValue,
252  Level level = LEVEL_INFO,
253  Stage stage = STATUS,
254  const char *msgContext = TxUCMConstants::defaultContext);
255 
260  virtual void logEnd (const std::string& key, const std::string& value)=0;
261  void logEnd (const char *key = TxUCMConstants::appEnd,
262  const char *value = "application ended");
263 //_______________________
264 //
265  virtual StUcmTasks *getTaskList ();
266  virtual StUcmTasks *getTaskList (int limit);
267  virtual StUcmTasks *getTaskList (int limit, int offset) = 0;
268 
269  virtual StUcmJobs *getJobList();
270  virtual StUcmJobs *getJobList(StRecord *task);
271  virtual StUcmJobs *getJobList(StRecord *task, int limit);
272  virtual StUcmJobs *getJobList(int limit);
273  virtual StUcmJobs *getJobList(int limit, int offset);
274  virtual StUcmJobs *getJobList(StRecord *task, int limit, int offset)=0;
275  virtual int getJobId(const char *requester, const char *taskBrokerId, int jobBrokerId) = 0;
276 
277  virtual StUcmEvents *getEventList();
278  virtual StUcmEvents *getEventList(StRecord *job);
279  virtual StUcmEvents *getEventList(StRecord *job,int limit);
280  virtual StUcmEvents *getEventList(int limit);
281  virtual StUcmEvents *getEventList(int limit, int offset);
282  virtual StUcmEvents *getEventList(StRecord *job,int limit, int offset)=0;
283 
284  virtual int queryTableSize(const char *tableName);
285  virtual int queryTableSize(const char *tableName, const char *where)=0;
286  virtual int queryTableSize(const char *tableName, const StRecord *where)=0;
287 
288  /* The current Db for the last selected job
289  *
290  * @param int dbJobID, value of Job ID
291  *
292  */
293  virtual void setDbJobID (int dbJobID)=0;
294  };
295 }
296 #ifndef TXEVENT_DEFAULT_IMPLEMENTAION
297 #define TXEVENT_DEFAULT_IMPLEMENTAION(classname) \
298  StUcmTasks *classname::getTaskList () \
299  { return TxEventLog::getTaskList() ; } \
300  StUcmTasks *classname::getTaskList (int limit) \
301  { return TxEventLog::getTaskList(limit); } \
302  StUcmJobs *classname::getJobList () \
303  { return TxEventLog::getJobList() ; } \
304  StUcmJobs *classname::getJobList (StRecord *task) \
305  { return TxEventLog::getJobList(task) ; } \
306  StUcmJobs *classname::getJobList (int limit) \
307  { return TxEventLog::getJobList(limit); } \
308  StUcmJobs *classname::getJobList (StRecord *task,int limit) \
309  { return TxEventLog::getJobList(task,limit); } \
310  StUcmJobs *classname::getJobList (int limit,int offset) \
311  { return TxEventLog::getJobList(limit,offset); } \
312  StUcmEvents *classname::getEventList () \
313  { return TxEventLog::getEventList() ; } \
314  StUcmEvents *classname::getEventList (StRecord *job) \
315  { return TxEventLog::getEventList(job) ; } \
316  StUcmEvents *classname::getEventList (int limit) \
317  { return TxEventLog::getEventList(limit); } \
318  StUcmEvents *classname::getEventList (StRecord *job,int limit) \
319  { return TxEventLog::getEventList(job,limit); } \
320  StUcmEvents *classname::getEventList (int limit,int offset) \
321  { return TxEventLog::getEventList(limit,offset); } \
322  int classname::queryTableSize (const char *table_name)\
323  { return TxEventLog::queryTableSize(table_name); } \
324  void classname::writeDown(const char *message) \
325  { return TxEventLog::writeDown(message); }
326 
327 #define TXEVENT_DEFAULT_IMPLEMENTAION_2(classname) \
328  int classname::getJobId (const char *requester, const char *taskBrokerId, int jobBrokerId)\
329  { assert(0 && "getJobId has not been implemented yet"); \
330  return 0; } \
331  StUcmTasks *classname::getTaskList (int limit, int offset) \
332  { assert(0 && "getTaskList has not been implemented yet"); \
333  return 0; } \
334  StUcmJobs *classname::getJobList (StRecord *task,int limit, int offset) \
335  { assert(0 && task && limit && offset && "getJobList has not been implemented yet"); \
336  return 0; } \
337  StUcmEvents *classname::getEventList (StRecord *job,int limit, int offset) \
338  { assert(0 && job && limit && offset&& "getEventList has not been implemented yet"); \
339  return 0; } \
340  int classname::queryTableSize (const char *table_name, const char *where) \
341  { assert(0 && table_name && where && "queryTableSize has not been implemented yet"); \
342  return 0; } \
343  int classname::queryTableSize (const char *table_name, const StRecord *where) \
344  { assert(0 && table_name && where && "queryTableSize has not been implemented yet"); \
345  return 0; } \
346  void classname::setDbJobID (int bJobID) \
347  { assert(0 && bJobID && "setDbJobID has not been implemented yet"); }
348 #endif
349 #endif
virtual void setBrokerTaskID(const std::string &brokerTaskID)=0
virtual void setEnvBrokerJobID(const std::string &envBrokerJobID)=0
virtual void logStart(const std::string &key, const std::string &value)=0
virtual void logTask(unsigned int size=1)=0
virtual void logEnd(const std::string &key, const std::string &value)=0
virtual void setRequesterName(const std::string &requester)=0
virtual void setBrokerJobID(int brokerJobID)=0
virtual void logJobSubmitLocation(const std::string &url)=0
virtual void logJobAttribute(const std::string &key, const std::string &value)=0
virtual void setEnvBrokerTaskID(const std::string &envBrokerTaskID)=0
virtual void logJobSubmitState(State state)=0
virtual void logEvent(const std::string &logMsg, Level level=LEVEL_INFO, Stage stage=STATUS, const std::string &msgContext=TxUCMConstants::defaultContext)=0
virtual void setContext(const std::string &context)=0
virtual void logJobSubmitID(const std::string &ID)=0