| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# IssueSeverity.cpp

Go to the documentation of this file.

    00001 #define GAUDIKERNEL_ISSUESEVERITY_CPP 1
    00002
    00003 #include "GaudiKernel/IssueSeverity.h"
    00004 #include "GaudiKernel/StatusCode.h"
    00005 #include "GaudiKernel/IIssueLogger.h"
    00006 #include "GaudiKernel/System.h"
    00007 #include "GaudiKernel/Bootstrap.h"
    00008 #include "GaudiKernel/ISvcLocator.h"
    00009
    00010 #include <sstream>
    00011
    00012 bool IssueSeverity::m_init(false);
    00013 IIssueLogger* IssueSeverity::m_ers(0);
    00014
    00015 void IssueSeverity::init() {
    00016   if (!m_init) {
    00017     m_init = true;
    00018     m_ers = Gaudi::svcLocator()->service<IIssueLogger>("IssueLogger").get();
    00019   }
    00020 }
    00021
    00022 IssueSeverity::~IssueSeverity() {
    00023
    00024   if (!m_reported) {
    00025     report();
    00026     // do stuff
    00027   }
    00028
    00029 }
    00030
    00031 void
    00032 IssueSeverity::report() {
    00033
    00034   if (m_ers != 0) {
    00035     m_ers->report(this);
    00036   } else {
    00037     std::cerr << *this << std::endl;
    00038   }
    00039   m_reported = true;
    00040
    00041 }
    00042
    00043
    00044 std::string
    00045 IssueSeverity::getOrigin() const {
    00046   std::ostringstream ost;
    00047   ost << m_file << ":" << m_line;
    00048   return ost.str();
    00049 }
    00050
    00051 IssueSeverity::operator StatusCode() const {
    00052   if (m_level == IssueSeverity::RECOVERABLE) {
    00053     return StatusCode(StatusCode::RECOVERABLE, *this);
    00054   } else if (m_level < IssueSeverity::ERROR) {
    00055     return StatusCode(StatusCode::SUCCESS, *this);
    00056   } else {
    00057     return StatusCode(StatusCode::FAILURE, *this);
    00058   }
    00059 }