CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/CondCore/DBCommon/src/SQLReport.cc

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