00001 #ifndef CONDCORE_DBCOMMON_LOGGER_H
00002 #define CONDCORE_DBCOMMON_LOGGER_H
00003
00004 #include <string>
00005
00006
00007
00008
00009
00012
00013
00014
00015
00016 namespace coral{
00017
00018 class IQuery;
00019 }
00020 namespace cond{
00021 class UserLogInfo;
00022 class LogDBEntry;
00023 class CoralTransaction;
00024 class Connection;
00025 class SequenceManager;
00026 class Logger{
00027 public:
00028 explicit Logger(Connection* connectionHandle);
00029 ~Logger();
00030 bool getWriteLock() throw ();
00031 bool releaseWriteLock() throw ();
00032
00033 void createLogDBIfNonExist();
00034
00035
00036
00037 void logOperationNow(
00038 const cond::UserLogInfo& userlogInfo,
00039 const std::string& destDB,
00040 const std::string& payloadToken,
00041 const std::string& iovtag,
00042 const std::string& iovtimetype,
00043 unsigned int payloadIdx
00044 );
00045
00046
00047
00048
00049 void logFailedOperationNow(
00050 const cond::UserLogInfo& userlogInfo,
00051 const std::string& destDB,
00052 const std::string& payloadToken,
00053 const std::string& iovtag,
00054 const std::string& iovtimetype,
00055 unsigned int payloadIdx,
00056 const std::string& exceptionMessage
00057 );
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 void LookupLastEntryByProvenance( const std::string& provenance,
00068 LogDBEntry& logentry,
00069 bool filterFailedOp=true) const;
00070
00071
00072
00073
00074
00075
00076
00077
00078 void LookupLastEntryByTag( const std::string& iovtag,
00079 LogDBEntry& logentry,
00080 bool filterFailedOp=true) const;
00081
00082 void LookupLastEntryByTag( const std::string& iovtag,
00083 const std::string & connectionStr,
00084 LogDBEntry& logentry,
00085 bool filterFailedOp=true) const;
00086
00087 private:
00088 void insertLogRecord(unsigned long long logId,
00089 const std::string& localtime,
00090 const std::string& destDB,
00091 const std::string& payloadToken,
00092 const cond::UserLogInfo& userLogInfo,
00093 const std::string& iovtag,
00094 const std::string& iovtimetype,
00095 unsigned int payloadIdx,
00096 const std::string& exceptionMessage);
00097
00098 Connection* m_connectionHandle;
00099 CoralTransaction& m_coraldb;
00100
00101 bool m_locked;
00102 coral::IQuery* m_statusEditorHandle;
00103 SequenceManager* m_sequenceManager;
00104 bool m_logTableExists;
00105 };
00106 }
00107 #endif