#include <DbFileHandler.h>
Public Member Functions | |
void | configure (const unsigned int runNumber, const DiskWritingParams &) |
DbFileHandler () | |
const DiskWritingParams & | getDiskWritingParams () const |
void | write (const std::string &) |
void | writeOld (const utils::TimePoint_t &, const std::string &) |
~DbFileHandler () | |
Private Member Functions | |
void | addReportHeader (std::ostream &, const utils::TimePoint_t &) const |
DbFileHandler (DbFileHandler const &) | |
void | openFile (std::ofstream &, const utils::TimePoint_t &) const |
DbFileHandler & | operator= (DbFileHandler const &) |
Private Attributes | |
DiskWritingParams | dwParams_ |
unsigned int | runNumber_ |
Handle the file used to pass information into SM database
Definition at line 26 of file DbFileHandler.h.
stor::DbFileHandler::DbFileHandler | ( | ) |
Definition at line 12 of file DbFileHandler.cc.
: runNumber_(0) {}
stor::DbFileHandler::~DbFileHandler | ( | ) | [inline] |
Definition at line 32 of file DbFileHandler.h.
{};
stor::DbFileHandler::DbFileHandler | ( | DbFileHandler const & | ) | [private] |
void stor::DbFileHandler::addReportHeader | ( | std::ostream & | msg, |
const utils::TimePoint_t & | timestamp | ||
) | const [private] |
Definition at line 77 of file DbFileHandler.cc.
References sistrip::runNumber_, and stor::utils::secondsSinceEpoch().
Referenced by write().
{ msg << "Timestamp:" << utils::secondsSinceEpoch(timestamp) << "\trun:" << runNumber_ << "\thost:" << dwParams_.hostName_ << "\tinstance:" << dwParams_.smInstanceString_ << "\t"; }
void stor::DbFileHandler::configure | ( | const unsigned int | runNumber, |
const DiskWritingParams & | params | ||
) |
Configure the db file writer
Definition at line 40 of file DbFileHandler.cc.
References dwParams_, convertSQLiteXML::runNumber, runNumber_, and write().
{ dwParams_ = params; runNumber_ = runNumber; write("BoR"); }
const DiskWritingParams& stor::DbFileHandler::getDiskWritingParams | ( | ) | const [inline] |
Return the DiskWritingParams used to configure the DbFileHandler
Definition at line 53 of file DbFileHandler.h.
References dwParams_.
{ return dwParams_; }
void stor::DbFileHandler::openFile | ( | std::ofstream & | outputFile, |
const utils::TimePoint_t & | timestamp | ||
) | const [private] |
Definition at line 50 of file DbFileHandler.cc.
References stor::utils::checkDirectory(), stor::utils::dateStamp(), lumiQueryAPI::msg, and dbtoconf::out.
Referenced by write(), and writeOld().
{ utils::checkDirectory(dwParams_.dbFilePath_); std::ostringstream dbfilename; dbfilename << dwParams_.dbFilePath_ << "/" << utils::dateStamp(timestamp) << "-" << dwParams_.hostName_ << "-" << dwParams_.smInstanceString_ << ".log"; outputFile.open( dbfilename.str().c_str(), std::ios_base::ate | std::ios_base::out | std::ios_base::app ); if (! outputFile.is_open() ) { std::ostringstream msg; msg << "Failed to open db log file " << dbfilename.str(); XCEPT_RAISE(stor::exception::DiskWriting, msg.str()); } }
DbFileHandler& stor::DbFileHandler::operator= | ( | DbFileHandler const & | ) | [private] |
void stor::DbFileHandler::write | ( | const std::string & | str | ) |
Write the string into the db file and prefix it with the report header. Close the file after each write.
Definition at line 27 of file DbFileHandler.cc.
References addReportHeader(), stor::utils::getCurrentTime(), openFile(), download_sqlite_cfg::outputFile, and cond::timestamp.
Referenced by configure().
{ const utils::TimePoint_t timestamp = utils::getCurrentTime(); std::ofstream outputFile; openFile(outputFile, timestamp); addReportHeader(outputFile, timestamp); outputFile << str.c_str(); outputFile << std::endl; outputFile.close(); }
void stor::DbFileHandler::writeOld | ( | const utils::TimePoint_t & | timestamp, |
const std::string & | str | ||
) |
Write the string into the db file. Close the file after each write.
Definition at line 17 of file DbFileHandler.cc.
References openFile(), and download_sqlite_cfg::outputFile.
{ std::ofstream outputFile; openFile(outputFile, timestamp); outputFile << str.c_str(); outputFile << std::endl; outputFile.close(); }
Definition at line 67 of file DbFileHandler.h.
Referenced by configure(), and getDiskWritingParams().
unsigned int stor::DbFileHandler::runNumber_ [private] |
Definition at line 68 of file DbFileHandler.h.
Referenced by configure().