/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/ers/ers-00-00-03/src/DefaultStream.cxx

Go to the documentation of this file.
00001 /*
00002  *  DefaultStream.cxx
00003  *  ERS
00004  *
00005  *  Created by Matthias Wiesmann on 21.01.05.
00006  *  Copyright 2005 CERN. All rights reserved.
00007  *
00008  */
00009 #include <iostream>
00010 
00011 #include "ers/DefaultStream.h"
00012 #include "ers/StreamFactory.h"
00013 #include "ers/InvalidReferenceIssue.h"
00014 
00016 const char* const ers::DefaultStream::KEY = "default" ; 
00017 const char* const ers::DefaultStream::VERBOSE_KEY = "verbose" ; 
00018 
00019 namespace {
00020     ers::Stream *create_stream(const std::string &protocol, const std::string &uri) { 
00021         
00022         if (protocol==ers::DefaultStream::KEY) {
00023             bool verbose = (uri == ers::DefaultStream::VERBOSE_KEY) ; 
00024             return new ers::DefaultStream(verbose) ;  
00025         } else {
00026         } 
00027         return 0 ; 
00028     } // 
00029     bool registered = ers::StreamFactory::instance()->register_factory(ers::DefaultStream::KEY,create_stream) ;
00030 } // anonymous namespace
00031 
00032 ers::DefaultStream::DefaultStream(bool verbose) {
00033     m_verbose = verbose ;
00034 } // DefaultStream
00035 
00036 
00037 ers::DefaultStream::~DefaultStream() {} 
00038 
00045 void ers::DefaultStream::send(const Issue *issue_ptr) {
00046     ERS_PRE_CHECK_PTR(issue_ptr); 
00047     try {
00048         const string_map_type *table = issue_ptr->get_value_table(); 
00049         const std::string & message_str = issue_ptr->get_value(Issue::MESSAGE_KEY) ;
00050         const std::string & severity_str = issue_ptr->get_value(Issue::SEVERITY_KEY) ;
00051         const std::string & position_str = issue_ptr->get_value(Issue::SOURCE_POSITION_KEY) ; 
00052         const std::string & date_str = issue_ptr->get_value(Issue::TIME_KEY); 
00053         
00054         std::ostream & out = issue_ptr->severity() < warning ? std::cout : std::cerr;
00055         
00056         out << severity_str << " at " << position_str << " (" << date_str << "): " << message_str << std::endl ; 
00057         if (m_verbose) {
00058             out << "-----------" << std::endl ; 
00059             for(string_map_type::const_iterator pos = table->begin();pos!=table->end();++pos) {
00060                 const std::string &key = pos->first ; 
00061                 const std::string &value = pos->second ; 
00062                 out << key << "=\t\"" << value << '\"' << std::endl ;
00063             } // for
00064                 out << "-----------" << std::endl ; 
00065         } // if long format
00066     } catch (std::ios_base::failure &ex) {
00067         throw ers::Issue(ERS_HERE,ers::error,&ex);
00068     } // catch generic I/O errors
00069    
00070 } // send
00071 

Generated on Tue Nov 29 22:58:27 2016 for BOSS_7.0.2 by  doxygen 1.4.7