StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TxEventLogFile.h
1 /*
2  * @file TxEventLogFile.h
3  * @author Roopa Pundaleeka
4  *
5  * @(#)cpp/api:$Id: TxEventLogFile.h,v 1.5 2010/09/17 19:34:54 fine Exp $
6  *
7  * TxEventLogFile 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_FILE_H
12 #define TX_EVENT_LOG_FILE_H
13 
14 #include "TxEventLog.h"
15 
16 #include <string>
17 #include <cstdlib>
18 #include <vector>
19 #include <sys/types.h>
20 #include <unistd.h>
21 #include <ctime>
22 #include <sstream>
23 #include <iostream>
24 #include <fstream>
25 #include <map>
26 
27 #include "TxUCMUtils.h"
28 
29 namespace TxLogging {
30  class TxEventLogFile: public TxEventLog {
31  protected:
38  virtual void writeDown(const std::string& message);
39  virtual void writeDown(const char *message);
40 
41  public:
47  TxEventLogFile ();
48 
54  virtual ~TxEventLogFile ();
55 
64  virtual void setEnvBrokerTaskID (const std::string& envBrokerTaskID);
65 
74  virtual void setEnvBrokerJobID (const std::string& envBrokerJobID);
75 
83  virtual void setBrokerTaskID (const std::string& brokerTaskID);
84 
92  virtual void setBrokerJobID (int brokerJobID);
93 
100  virtual void setRequesterName (const std::string& requester);
101 
107  virtual void setContext (const std::string& context);
108 
113  virtual void logStart (const std::string& key, const std::string& value);
114 
124  virtual void logJobAttribute (const std::string& key, const std::string& value);
132  virtual void logJobSubmitLocation (const std::string& url);
133  virtual void setJobSubmitLocation (const std::string& url);
134 
141  virtual void logJobSubmitState (State state);
142  virtual void setJobSubmitState (State state);
143 
151  virtual void logTask (unsigned int size=1);
152 
165  virtual void logTask (const std::string& taskAttributes);
166 
174  virtual void logJobSubmitID (const std::string& ID);
175  virtual void setJobSubmitID (const std::string& ID);
176 
187  virtual void logEvent (const std::string& logMsg,
188  Level level = LEVEL_INFO,
189  Stage stage = STATUS,
190  const std::string& msgContext = TxUCMConstants::defaultContext);
191 
203  virtual void logEvent (const std::string& userKey,
204  const std::string& userValue,
205  Level level = LEVEL_INFO,
206  Stage stage = STATUS,
207  const std::string& msgContext = TxUCMConstants::defaultContext);
208 
213  virtual void logEnd (const std::string& key,
214  const std::string& value);
215 
216  private:
220  virtual void readProperties ();
221 
225  void setDefaults ();
226 
230  const char* createHeader ();
231 
235  void writeMessage (const std::string& event,
236  const std::string& context,
237  const Level& level,
238  const Stage& stage,
239  const std::string& key,
240  const std::string& value);
241 
242  std::string brokerJobID, brokerTaskID, requester, context;
243  std::map <std::string, std::string> ucmLogProps;
244  std::string timestamp, logFilePath;
245  std::string username, hostname;
246  bool startMsgWritten;
247 
248 
249  virtual StUcmTasks *getTaskList ();
250  virtual StUcmTasks *getTaskList (int limit);
251  virtual StUcmTasks *getTaskList (int limit, int offset);
252 
253  virtual StUcmJobs *getJobList();
254  virtual StUcmJobs *getJobList(StRecord *task);
255  virtual StUcmJobs *getJobList(StRecord *task, int limit);
256  virtual StUcmJobs *getJobList(int limit);
257  virtual StUcmJobs *getJobList(int limit, int offset);
258  virtual StUcmJobs *getJobList(StRecord *task, int limit, int offset);
259  virtual int getJobId(const char *reqName,const char *taskBrokerId, int jobBrokerId);
260 
261  virtual StUcmEvents *getEventList();
262  virtual StUcmEvents *getEventList(StRecord *job);
263  virtual StUcmEvents *getEventList(StRecord *job,int limit);
264  virtual StUcmEvents *getEventList(int limit);
265  virtual StUcmEvents *getEventList(int limit, int offset);
266  virtual StUcmEvents *getEventList(StRecord *job,int limit, int offset);
267 
268  virtual void setDbJobID (int bJobID);
269 
270  virtual int queryTableSize(const char *tableName);
271  virtual int queryTableSize(const char *tableName, const char *where);
272  virtual int queryTableSize(const char *tableName, const StRecord *where);
273 
274  };
275 }
276 #endif
virtual void logJobSubmitLocation(const std::string &url)
virtual void logJobSubmitID(const std::string &ID)
virtual void logStart(const std::string &key, const std::string &value)
virtual void logEnd(const std::string &key, const std::string &value)
virtual void logEvent(const std::string &logMsg, Level level=LEVEL_INFO, Stage stage=STATUS, const std::string &msgContext=TxUCMConstants::defaultContext)
virtual void setEnvBrokerTaskID(const std::string &envBrokerTaskID)
virtual void setEnvBrokerJobID(const std::string &envBrokerJobID)
virtual void logJobAttribute(const std::string &key, const std::string &value)
virtual void setRequesterName(const std::string &requester)
virtual void setBrokerJobID(int brokerJobID)
virtual void writeDown(const std::string &message)
virtual void logTask(unsigned int size=1)
virtual void setContext(const std::string &context)
virtual void logJobSubmitState(State state)
virtual void setBrokerTaskID(const std::string &brokerTaskID)