00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiKernel/src/Lib/MsgStream.cpp,v 1.1.1.1 2001/04/18 18:14:18 tlindner Exp $ 00002 //==================================================================== 00003 // MsgStream.cpp 00004 //-------------------------------------------------------------------- 00005 // 00006 // Package : System ( The LHCb Offline System) 00007 // 00008 // Description: Class to ease error logging to the message service 00009 // 00010 // Author : M.Frank 00011 // History : 00012 // +---------+----------------------------------------------+--------- 00013 // | Date | Comment | Who 00014 // +---------+----------------------------------------------+--------- 00015 // | 29/10/98| Initial version | MF 00016 // +---------+----------------------------------------------+--------- 00017 // 00018 //==================================================================== 00019 #define KERNEL_MSGSTREAM_CPP 00020 00021 #include <iostream> 00022 00023 #include "GaudiKernel/MsgStream.h" 00024 #include "GaudiKernel/Message.h" 00025 #include "GaudiKernel/IMessageSvc.h" 00026 00027 MsgStream::MsgStream(IMessageSvc* svc, int) 00028 : m_service(svc), 00029 m_source(""), 00030 m_active(false) 00031 { 00032 setLevel((0==svc) ? MSG::INFO : svc->outputLevel()); 00033 } 00034 00035 MsgStream::MsgStream(IMessageSvc* svc, const std::string& source, int) 00036 : m_service(svc), 00037 m_source(source), 00038 m_active(false) 00039 { 00040 setLevel((0==svc) ? MSG::INFO : svc->outputLevel(source)); 00041 } 00042 00043 MsgStream::~MsgStream() { 00044 } 00045 00046 MsgStream& MsgStream::doOutput() { 00047 if ( isActive() ) { 00048 // long pos = stream().tellp(); 00049 // char *data = (char*)m_buffer.data(); 00050 //if ( data[pos-1] != '\0' ) 00051 m_stream << std::ends; 00052 Message msg(m_source,m_currLevel,m_stream.str()); 00053 if ( m_service != 0 ) { 00054 m_service->reportMessage (msg); 00055 } 00056 else { 00057 std::cout << msg << std::endl; 00058 } 00059 } 00060 // memset((char*)m_buffer.data(),0,m_buffer.size()); 00061 m_stream.freeze(false); 00062 m_stream.flush(); 00063 m_stream.seekp(0); 00064 return *this; 00065 } 00066 00067
1.2.3 written by Dimitri van Heesch,
© 1997-2000