CMS 3D CMS Logo

SQLReport.cc

Go to the documentation of this file.
00001 #include "CondCore/DBCommon/interface/SQLReport.h"
00002 #include "CondCore/DBCommon/interface/DBSession.h"
00003 #include "CondCore/DBCommon/interface/Exception.h"
00004 #include "RelationalAccess/IMonitoringReporter.h"
00005 #include <fstream>
00006 
00007 static std::string SQLREPORT_DEFAULT_FILENAME("sqlreport.out");
00008 
00009 void cond::SQLReport::reportForConnection(const std::string& connectionString){
00010   m_report << "-- connection: "<< connectionString << std::endl;
00011   m_session.monitoringReporter().reportToOutputStream( connectionString, m_report );
00012 }
00013 
00014 bool cond::SQLReport::putOnFile(std::string fileName){
00015   std::ofstream outFile;
00016   if(fileName.empty()) fileName.append(SQLREPORT_DEFAULT_FILENAME);
00017   outFile.open(fileName.c_str());
00018   if(!outFile.good()){
00019     std::stringstream msg;
00020     msg << "Cannot open the output file \""<<fileName<<"\"";
00021     outFile.close();
00022     throw cond::Exception(msg.str());
00023   }
00024   outFile << m_report.str();
00025   outFile.flush();
00026   outFile.close();
00027   return true;
00028 }

Generated on Tue Jun 9 17:26:06 2009 for CMSSW by  doxygen 1.5.4