#include <DbmLogFile.h>
Public Member Functions | |
| DbmLogFile (const string &fileName="", UInt_t dbNo=0) | |
| virtual | ~DbmLogFile () |
| Bool_t | IsValid () const |
| ofstream * | GetStream () |
| void | LogCmd (const string &cmd, const DbmCmdOptions &opts) |
| void | LogMsg (const string &msg, Bool_t addDateStamp=kTRUE) |
| void | LogRec (const DbiValidityRec *vrec=0) |
| void | LogRec (const string tableName, UInt_t seqNo) |
Private Attributes | |
| UInt_t | fDbNo |
| std::list< UInt_t > | fLogDBSrcNos |
| std::map< UInt_t, UInt_t > | fLogNumSeqNo |
| std::map< UInt_t, UInt_t > | fLogSeqNoMax |
| std::map< UInt_t, UInt_t > | fLogSeqNoMin |
| string | fLogTableName |
| ofstream * | fLogFile |
|
||||||||||||
|
Definition at line 45 of file DbmLogFile.cxx. 00045 : 00046 fDbNo(dbNo), 00047 fLogFile(0) 00048 { 00049 // 00050 // Purpose: Default constructor 00051 // 00052 // Arguments: 00053 // fileName in File name. Default = "". 00054 // dbNo in Database no. 00055 // 00056 // Return: n/a 00057 // 00058 // Contact: N. West 00059 // 00060 // Specification:- 00061 // ============= 00062 // 00063 // o Create a DbmLogFile. 00064 00065 00066 // Program Notes:- 00067 // ============= 00068 00069 // None. 00070 00071 LEA_CTOR //Leak Checker 00072 MSG("Dbm", Msg::kVerbose) << "Creating DbmLogFile" << endl; 00073 00074 if ( fileName == "") return; 00075 00076 fLogFile = new ofstream(fileName.c_str(),ios::app); 00077 if ( ! fLogFile->is_open() ) { 00078 MSG("Dbm",Msg::kError) << "Cannot open " << fileName << endl; 00079 return; 00080 } 00081 }
|
|
|
Definition at line 85 of file DbmLogFile.cxx. References fLogFile, LEA_DTOR, LogRec(), and MSG. 00085 {
00086 //
00087 //
00088 // Purpose: Destructor
00089 //
00090 // Arguments:
00091 // None.
00092 //
00093 // Return: n/a
00094 //
00095 // Contact: N. West
00096 //
00097 // Specification:-
00098 // =============
00099 //
00100 // o Complete last LogRec (if any) and Destroy DbmLogFile.
00101
00102
00103 // Program Notes:-
00104 // =============
00105
00106 // None.
00107
00108 LEA_DTOR //Leak Checker
00109
00110 MSG("Dbm", Msg::kVerbose) << "Destroying DbmLogFile" << endl;
00111
00112 LogRec(0);
00113 delete fLogFile;
00114 fLogFile = 0;
00115
00116 }
|
|
|
Definition at line 44 of file DbmLogFile.h. Referenced by DbmModule::Import().
|
|
|
Definition at line 41 of file DbmLogFile.h. Referenced by LogCmd(), LogMsg(), and LogRec().
|
|
||||||||||||
|
Definition at line 120 of file DbmLogFile.cxx. References DbmCmdOptions::GetOpts(), IsValid(), and LogMsg(). Referenced by DbmModule::ExportTables(), and DbmModule::Import(). 00121 {
00122 //
00123 //
00124 // Purpose: Record command plus options into the log.
00125 //
00126 // Arguments:
00127 // cmd in The command to be executed.
00128 // opts in The options for the current command.
00129 //
00130 // Return: n/a.
00131 //
00132 // Contact: N. West
00133 //
00134 // Specification:-
00135 // =============
00136 //
00137 // o Record command plus options into the log.
00138
00139 // Program Notes:-
00140 // =============
00141
00142 // None.
00143
00144 if ( ! IsValid() ) return;
00145 //Skip a line.
00146 this->LogMsg("",kFALSE);
00147 string msg(cmd);
00148 msg += " ";
00149 msg += opts.GetOpts();
00150
00151 // Tidy up command by placing each option on a new line.
00152 string insert("+\n ");
00153 UInt_t locOpt = 0;
00154 while ( (locOpt = msg.find("--",locOpt)) != string::npos ) {
00155 msg.insert(locOpt,insert);
00156 locOpt += insert.size() + 2;
00157 }
00158 this->LogMsg(msg);
00159 return;
00160
00161
00162 }
|
|
||||||||||||
|
Definition at line 165 of file DbmLogFile.cxx. References IsValid(), and Dbi::MakeDateTimeString(). Referenced by DbmModule::ApplySQLFixup(), and LogCmd(). 00166 {
00167 //
00168 //
00169 // Purpose: Record date-stamped message into the log.
00170 //
00171 // Arguments:
00172 // msg in The message to be recorded.
00173 // addDateStamp in If true (default) prefix date stamp.
00174 //
00175 // Contact: N. West
00176
00177 if ( ! IsValid() ) return;
00178 if ( addDateStamp ) {
00179 VldTimeStamp now;
00180 (*fLogFile) << Dbi::MakeDateTimeString( now )
00181 << " ";
00182 }
00183 (*fLogFile) << msg << endl;
00184
00185 return;
00186
00187
00188 }
|
|
||||||||||||
|
Definition at line 223 of file DbmLogFile.cxx. References fDbNo, find(), fLogDBSrcNos, fLogNumSeqNo, fLogSeqNoMax, fLogSeqNoMin, fLogTableName, DbiResultPtr< T >::GetRow(), and IsValid(). 00223 {
00224 //
00225 //
00226 // Purpose: Record DbiValidityRec I/O into the log.
00227 //
00228 // Arguments:
00229 // tableName in Table name to be logged.. May be null (just to
00230 // Flush out last log summary).
00231 // seqNo in SeqNo to be logged.
00232 //
00233 // Return: None.
00234 //
00235 // Contact: N. West
00236 //
00237 // Specification:-
00238 // =============
00239 //
00240 // o Record summary of DbiValidityRec I/O into the log.
00241
00242 // Program Notes:-
00243 // =============
00244
00245 // None.
00246
00247 if ( ! IsValid() ) return;
00248
00249 // If there is a change of table name output any buffered log info.
00250 if ( tableName != fLogTableName ) {
00251 if ( fLogDBSrcNos.size() ) {
00252 list<UInt_t>::const_iterator itr = fLogDBSrcNos.begin();
00253 list<UInt_t>::const_iterator itrEnd = fLogDBSrcNos.end();
00254 while ( itr != itrEnd ) {
00255 UInt_t dbSrcNo = *itr;
00256 (*fLogFile) << " "
00257 << fLogTableName << " "
00258 << fLogNumSeqNo[dbSrcNo] << " recs: "
00259 << fLogSeqNoMin[dbSrcNo];
00260 if ( fLogSeqNoMin[dbSrcNo] != fLogSeqNoMax[dbSrcNo]
00261 ) (*fLogFile) << ".." << fLogSeqNoMax[dbSrcNo];
00262 (*fLogFile) << endl;
00263 ++itr;
00264 }
00265 }
00266 if ( tableName == "DBILOGENTRY"
00267 ) (*fLogFile) << "Start of update log entries..." << endl;
00268 else if ( fLogTableName == "DBILOGENTRY"
00269 ) (*fLogFile) << "End of update log entries..." << endl;
00270
00271 fLogTableName = tableName;
00272 fLogDBSrcNos.clear();
00273 fLogNumSeqNo.clear();
00274 fLogSeqNoMin.clear();
00275 fLogSeqNoMax.clear();
00276
00277 }
00278
00279 // Buffer info for next summary.
00280 if ( tableName != "" ) {
00281 UInt_t dbSrcNo = seqNo/(Dbi::kMAXLOCALSEQNO+1);
00282 if ( find(fLogDBSrcNos.begin(), fLogDBSrcNos.end(), dbSrcNo)
00283 == fLogDBSrcNos.end() ) {
00284 fLogDBSrcNos.push_back(dbSrcNo);
00285 fLogSeqNoMin[dbSrcNo] = seqNo;
00286 fLogSeqNoMax[dbSrcNo] = seqNo;
00287 fLogNumSeqNo[dbSrcNo] = 1;
00288 }
00289 else {
00290 if ( fLogSeqNoMin[dbSrcNo] > seqNo ) fLogSeqNoMin[dbSrcNo] = seqNo;
00291 if ( fLogSeqNoMax[dbSrcNo] < seqNo ) fLogSeqNoMax[dbSrcNo] = seqNo;
00292 ++fLogNumSeqNo[dbSrcNo];
00293 }
00294 }
00295
00296 // Record DbiLogEntrys directly into the file.
00297
00298 if ( tableName == "DBILOGENTRY" ) {
00299 DbiResultPtr<DbiLogEntry> rp("DBILOGENTRY",seqNo,fDbNo);
00300 const DbiLogEntry* le = rp.GetRow(0);
00301 if ( le ) (*fLogFile) << *le << endl;
00302 }
00303
00304 }
|
|
|
Definition at line 191 of file DbmLogFile.cxx. References DbiValidityRec::GetSeqNo(), DbiTableProxy::GetTableName(), DbiValidityRec::GetTableProxy(), and IsValid(). Referenced by DbmModule::ExportTable(), DbmModule::Import(), and ~DbmLogFile(). 00191 {
00192 //
00193 //
00194 // Purpose: Record DbiValidityRec I/O into the log.
00195 //
00196 // Arguments:
00197 // vrec in The DbiValidityRec to be recorded.
00198 // May be zero (just to flush out last log
00199 // summary).
00200 //
00201 // Return: None.
00202 //
00203 // Contact: N. West
00204 //
00205 // Specification:-
00206 // =============
00207 //
00208 // o Record summary of DbiValidityRec I/O into the log.
00209
00210 // Program Notes:-
00211 // =============
00212
00213 // None.
00214
00215 if ( ! IsValid() ) return;
00216 string tableName = vrec ? vrec->GetTableProxy()->GetTableName() : "";
00217 UInt_t seqNo = vrec ? vrec->GetSeqNo() : 0;
00218 LogRec(tableName,seqNo);
00219
00220 }
|
|
|
Definition at line 55 of file DbmLogFile.h. Referenced by LogRec(). |
|
|
Definition at line 56 of file DbmLogFile.h. Referenced by LogRec(). |
|
|
Definition at line 63 of file DbmLogFile.h. Referenced by ~DbmLogFile(). |
|
|
Definition at line 58 of file DbmLogFile.h. Referenced by LogRec(). |
|
|
Definition at line 59 of file DbmLogFile.h. Referenced by LogRec(). |
|
|
Definition at line 60 of file DbmLogFile.h. Referenced by LogRec(). |
|
|
Definition at line 61 of file DbmLogFile.h. Referenced by LogRec(). |
1.3.9.1