StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TxUcmlog.h
1 // Logic Tier //
4 class TXUcmLog {
5 
6 enum EFacility { ETask, EJob, EEvent, EBroker, ETransport };
7 enum EStage { EBegin, EEnd, EPRogress };
8 
9 // Presentation layer
10 // The class generates the record to file with UCM system
11 // Each record may contain the list of the optional attribites
12 // followed by the optional user message.
13 
14 // It is supposed to support the list of the "known attributes",
15 // where the list of attributes is defined by the current Db schema
16 // or other external "configuration" facility.
17 
18 // All "unknown" attributes are treated as the ordinar "user's message"
19 
20 protected:
21  TXUcmLog();
22 public:
23  virtual ~TXUcmLog(){ closelog();}
24 
25  // Logging options other than the defaults
26  static TXUcmLog *openlog(const char* ident,int logopt, EFacility facility);
27  static TXUcmLog *openlog(const char* ident,int logopt);
28  static TXUcmLog *openlog(const char* ident="ucmlog");
29 
30  // Generate and Send the ucm record,
31  // the optional attributes, and the optional user's message
32  void ucmlog(unsigned int pripority, const char*message);
33 
34  // Generate and Send the record that may contains the attributes only
35  void ucmlog(const char*message=0);
36 
37  // Generates and Send the ucm record that contains
38  // Begin/End tag, the optional attributes and optional user's message
39  void ucmlogevent(EStage stage=EBegin, const char*message=0);
40 
41  // send the message that contains the attributes and tags only
42  void ucmlogmessage(const char*message=0);
43 
44  // send "Job finished" record and close the ucm systen.
45  int closelog();
46 
47  // register the task with the ID provided and make it current
48  void openTask(unsigned int brokerTaskID);
49 
50  // register the job of the current task the ID provided
51  void openJob(unsigned int brokerJobID);
52 
53  // register the current task
54  void openTask();
55 
56  // register the current job
57  void openJob();
58 
59  void setlogmask(unsigned int logmask);
60  // set the pair of the attribute : value
61  void setAttribute(const char *key, const char * value);
62 
63  // set the current task ID
64  void setTaskId(unsigned int brokerTaskID);
65 
66  // set the current job ID
67  void setJobId(unsigned int brokerJobID);
68 
69  // set the current event ID
70  void setEventId(unsigned int taskId);
71 
72  // return the attribute value by the attribute key
73  const char *getAttribute(const char *key) const;
74 
75  // return the attribute value by the attribute index
76  const char *getAttribute(int attributeIndex) const;
77 
78  // return the number of the different attributes;
79  int getNumberofAttributes() const;
80 
81  // Reset the "key" attribute
82  void resetAttribute(const char *key);
83 
84  // Reset all attributes (clean up the "known" attribute list)
85  void resetAttributes();
86 
87  unsigned long getTaskId() const;
88  unsigned long getJobId() const;
89  unsigned long getEventId() const;
90 
91  bool isTaskOpen() const;
92  bool isJobOpen() const;
93 };
94 
95 /*
96 ------------------------------------------------------------------------------------------------------------------
97 Message
98 
99  PRI HEADER MESSAGE
100  <Facility*8 + Severity> TIMESTAMP HOSTNAME
101  Mmm dd hh:mm:ss rcas6002.rcf.bnl.gov TAG : CONTENT
102  Task[taskid] : start
103  Job[jobid] : Task[Taskid] start
104  Job[jobid] : Task[Taskid] finish
105  Event[eventid]: Job[jobid], Task[taskid] [attribute=value,] message start
106  Event[eventid]: Job[jobid], Task[taskid] finish
107  Message : Job[jobid], Task[taskid] attribute=value message
108 
109 ------------------------------------------------------------------------------------------------------------------
110 
111 */