00001 00002 // Logic Tier // 00004 class TXUcmLog { 00005 00006 enum EFacility { ETask, EJob, EEvent, EBroker, ETransport }; 00007 enum EStage { EBegin, EEnd, EPRogress }; 00008 00009 // Presentation layer 00010 // The class generates the record to file with UCM system 00011 // Each record may contain the list of the optional attribites 00012 // followed by the optional user message. 00013 00014 // It is supposed to support the list of the "known attributes", 00015 // where the list of attributes is defined by the current Db schema 00016 // or other external "configuration" facility. 00017 00018 // All "unknown" attributes are treated as the ordinar "user's message" 00019 00020 protected: 00021 TXUcmLog(); 00022 public: 00023 virtual ~TXUcmLog(){ closelog();} 00024 00025 // Logging options other than the defaults 00026 static TXUcmLog *openlog(const char* ident,int logopt, EFacility facility); 00027 static TXUcmLog *openlog(const char* ident,int logopt); 00028 static TXUcmLog *openlog(const char* ident="ucmlog"); 00029 00030 // Generate and Send the ucm record, 00031 // the optional attributes, and the optional user's message 00032 void ucmlog(unsigned int pripority, const char*message); 00033 00034 // Generate and Send the record that may contains the attributes only 00035 void ucmlog(const char*message=0); 00036 00037 // Generates and Send the ucm record that contains 00038 // Begin/End tag, the optional attributes and optional user's message 00039 void ucmlogevent(EStage stage=EBegin, const char*message=0); 00040 00041 // send the message that contains the attributes and tags only 00042 void ucmlogmessage(const char*message=0); 00043 00044 // send "Job finished" record and close the ucm systen. 00045 int closelog(); 00046 00047 // register the task with the ID provided and make it current 00048 void openTask(unsigned int brokerTaskID); 00049 00050 // register the job of the current task the ID provided 00051 void openJob(unsigned int brokerJobID); 00052 00053 // register the current task 00054 void openTask(); 00055 00056 // register the current job 00057 void openJob(); 00058 00059 void setlogmask(unsigned int logmask); 00060 // set the pair of the attribute : value 00061 void setAttribute(const char *key, const char * value); 00062 00063 // set the current task ID 00064 void setTaskId(unsigned int brokerTaskID); 00065 00066 // set the current job ID 00067 void setJobId(unsigned int brokerJobID); 00068 00069 // set the current event ID 00070 void setEventId(unsigned int taskId); 00071 00072 // return the attribute value by the attribute key 00073 const char *getAttribute(const char *key) const; 00074 00075 // return the attribute value by the attribute index 00076 const char *getAttribute(int attributeIndex) const; 00077 00078 // return the number of the different attributes; 00079 int getNumberofAttributes() const; 00080 00081 // Reset the "key" attribute 00082 void resetAttribute(const char *key); 00083 00084 // Reset all attributes (clean up the "known" attribute list) 00085 void resetAttributes(); 00086 00087 unsigned long getTaskId() const; 00088 unsigned long getJobId() const; 00089 unsigned long getEventId() const; 00090 00091 bool isTaskOpen() const; 00092 bool isJobOpen() const; 00093 }; 00094 00095 /* 00096 ------------------------------------------------------------------------------------------------------------------ 00097 Message 00098 00099 PRI HEADER MESSAGE 00100 <Facility*8 + Severity> TIMESTAMP HOSTNAME 00101 Mmm dd hh:mm:ss rcas6002.rcf.bnl.gov TAG : CONTENT 00102 Task[taskid] : start 00103 Job[jobid] : Task[Taskid] start 00104 Job[jobid] : Task[Taskid] finish 00105 Event[eventid]: Job[jobid], Task[taskid] [attribute=value,] message start 00106 Event[eventid]: Job[jobid], Task[taskid] finish 00107 Message : Job[jobid], Task[taskid] attribute=value message 00108 00109 ------------------------------------------------------------------------------------------------------------------ 00110 00111 */
1.5.9