#include <DefaultStream.h>
Inheritance diagram for ers::DefaultStream:
Public Member Functions | |
DefaultStream (bool verbose=false) | |
~DefaultStream () | |
void | send (const Issue *ptr) |
operator std::string () const | |
virtual Issue * | receive () |
Receives an issue from the stream. | |
virtual void | print_to (std::ostream &stream) const |
Static Public Attributes | |
static const char *const | KEY = "default" |
static const char *const | VERBOSE_KEY = "verbose" |
static const char *const | NULL_STREAM_KEY = "null" |
Protected Attributes | |
bool | m_verbose |
This class displas an Issue on the standard error stream This class is meant to be used as default stream for simple on screen display. More advanced streams are offered in the System
package This stream only sends output to the standard error stream. To select this stream, simply use the default
string key. You can get a verbose output by
Definition at line 28 of file DefaultStream.h.
ers::DefaultStream::DefaultStream | ( | bool | verbose = false |
) |
Definition at line 32 of file DefaultStream.cxx.
References m_verbose.
00032 { 00033 m_verbose = verbose ; 00034 } // DefaultStream
ers::DefaultStream::~DefaultStream | ( | ) |
ers::Stream::operator std::string | ( | ) | const [inherited] |
Definition at line 35 of file Stream.cxx.
References ers::Stream::print_to().
00035 { 00036 std::ostringstream stream ; 00037 print_to(stream); 00038 return stream.str(); 00039 } // to string
void ers::Stream::print_to | ( | std::ostream & | stream | ) | const [virtual, inherited] |
Reimplemented in ers::FIFOStream, ers::FilterStream, and ers::HumanStream.
Definition at line 59 of file Stream.cxx.
References ers::Stream::NULL_STREAM_KEY.
Referenced by ers::Stream::operator std::string().
00059 { 00060 stream << NULL_STREAM_KEY << ':' ; 00061 } // print_to
ers::Issue * ers::Stream::receive | ( | ) | [virtual, inherited] |
Receives an issue from the stream.
Reads an isssue on the stream
Reimplemented in ers::FIFOStream.
Definition at line 55 of file Stream.cxx.
void ers::DefaultStream::send | ( | const Issue * | issue_ptr | ) | [virtual] |
We print the stream in a semi-tabbed mode. The message is first printed out, then a list of all properties.
issue_ptr | reference to the issue to print |
Reimplemented from ers::Stream.
Definition at line 45 of file DefaultStream.cxx.
References ers::error, ERS_HERE, ERS_PRE_CHECK_PTR, ers::Issue::get_value(), ers::Issue::get_value_table(), key, m_verbose, ers::Issue::MESSAGE_KEY, boss::pos, ers::Issue::severity(), ers::Issue::SEVERITY_KEY, ers::Issue::SOURCE_POSITION_KEY, deljobs::string, ers::Issue::TIME_KEY, and ers::warning.
00045 { 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
const char *const ers::DefaultStream::KEY = "default" [static] |
The key for this stream is default
the URI field is ignored
Definition at line 32 of file DefaultStream.h.
Referenced by create_stream(), and ers::StreamFactory::key_for_severity().
bool ers::DefaultStream::m_verbose [protected] |
const char *const ers::Stream::NULL_STREAM_KEY = "null" [static, inherited] |
Key for discard stream
Definition at line 39 of file Stream.h.
Referenced by create_stream(), and ers::Stream::print_to().
const char *const ers::DefaultStream::VERBOSE_KEY = "verbose" [static] |