CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Logger.h
Go to the documentation of this file.
1 #ifndef CONDCORE_DBCOMMON_LOGGER_H
2 #define CONDCORE_DBCOMMON_LOGGER_H
3 
5 #include <string>
6 //#include <iostream>
7 //
8 // Package: CondCore/DBCommon
9 // Class : Logger
10 //
13 //
14 // Author: Zhen Xie
15 //
16 //#include "UserLogInfo.h"
17 namespace coral{
18  //class ISchema;
19  class IQuery;
20 }
21 namespace cond{
22  class UserLogInfo;
23  class LogDBEntry;
24  class SequenceManager;
25  class Logger{
26  public:
27  explicit Logger(DbSession& sessionHandle);
28  ~Logger();
29  bool getWriteLock() throw ();
30  bool releaseWriteLock() throw ();
31  //NB. for oracle only schema owner can do this
32  void createLogDBIfNonExist();
33  //
34  //the current local time will be registered as execution time
35  // payloadName and containerName are also logged but they are deduced from payloadToken
36  void logOperationNow(
37  const cond::UserLogInfo& userlogInfo,
38  const std::string& destDB,
39  const std::string& payloadToken,
40  const std::string& iovtag,
41  const std::string& iovtimetype,
42  unsigned int payloadIdx,
43  unsigned long long lastSince
44  );
45  //
46  //the current local time will be registered as execution time
47  //
48  // payloadName and containerName are also logged but they are deduced from payloadToken
50  const cond::UserLogInfo& userlogInfo,
51  const std::string& destDB,
52  const std::string& payloadToken,
53  const std::string& iovtag,
54  const std::string& iovtimetype,
55  unsigned int payloadIdx,
56  unsigned long long lastSince,
57  const std::string& exceptionMessage
58  );
59  //
60  // Here we query the log for the last entry for these payloads.
61  // Parameter LogDBEntry& result is both input and output
62  // As input, it defines query condition.
63  // Last: in the sense of max rowid satisfies the requirement
64  // Note: if empty logentry is given, the absolute max is returned which
65  // normally is useless.
66  // return empty struct is no result found
67  //
68  void LookupLastEntryByProvenance( const std::string& provenance,
69  LogDBEntry& logentry,
70  bool filterFailedOp=true) const;
71  //
72  // Here we query the log for the last entry for these payloads.
73  // Parameter LogDBEntry& result is both input and output
74  // As input, it defines query condition.
75  // Last: in the sense of max rowid satisfies the requirement
76  // Note: if empty logentry is given, the absolute max is returned which
77  // normally is useless.
78  //
79  void LookupLastEntryByTag( const std::string& iovtag,
80  LogDBEntry& logentry,
81  bool filterFailedOp=true) const;
82 
83  void LookupLastEntryByTag( const std::string& iovtag,
84  const std::string & connectionStr,
85  LogDBEntry& logentry,
86  bool filterFailedOp=true) const;
87 
88  private:
89  void insertLogRecord(unsigned long long logId,
90  const std::string& utctime,
91  const std::string& destDB,
92  const std::string& payloadToken,
93  const cond::UserLogInfo& userLogInfo,
94  const std::string& iovtag,
95  const std::string& iovtimetype,
96  unsigned int payloadIdx,
97  unsigned long long lastSince,
98  const std::string& exceptionMessage);
99 
101  //coral::ISchema& m_schema;
102  bool m_locked;
103  coral::IQuery* m_statusEditorHandle;
106  };
107 }//ns cond
108 #endif
SequenceManager * m_sequenceManager
Definition: Logger.h:104
bool m_locked
Definition: Logger.h:102
bool releaseWriteLock()
Definition: Logger.cc:51
DbSession m_sessionHandle
Definition: Logger.h:100
void LookupLastEntryByProvenance(const std::string &provenance, LogDBEntry &logentry, bool filterFailedOp=true) const
Definition: Logger.cc:173
void logOperationNow(const cond::UserLogInfo &userlogInfo, const std::string &destDB, const std::string &payloadToken, const std::string &iovtag, const std::string &iovtimetype, unsigned int payloadIdx, unsigned long long lastSince)
Definition: Logger.cc:128
coral::IQuery * m_statusEditorHandle
Definition: Logger.h:103
void createLogDBIfNonExist()
Definition: Logger.cc:61
void insertLogRecord(unsigned long long logId, const std::string &utctime, const std::string &destDB, const std::string &payloadToken, const cond::UserLogInfo &userLogInfo, const std::string &iovtag, const std::string &iovtimetype, unsigned int payloadIdx, unsigned long long lastSince, const std::string &exceptionMessage)
Definition: Logger.cc:331
void LookupLastEntryByTag(const std::string &iovtag, LogDBEntry &logentry, bool filterFailedOp=true) const
Definition: Logger.cc:325
bool m_logTableExists
Definition: Logger.h:105
Logger(DbSession &sessionHandle)
Definition: Logger.cc:31
bool getWriteLock()
Definition: Logger.cc:34
void logFailedOperationNow(const cond::UserLogInfo &userlogInfo, const std::string &destDB, const std::string &payloadToken, const std::string &iovtag, const std::string &iovtimetype, unsigned int payloadIdx, unsigned long long lastSince, const std::string &exceptionMessage)
Definition: Logger.cc:150