00001 #include "GaudiMessages/GaudiMessages.h" 00002 #include "GaudiKernel/ServiceHandle.h" 00003 00004 static IMessageSvc* gsMsgSvc = 0; 00005 00006 IMessageSvc* msgSvc() 00007 { 00008 if (gsMsgSvc) return gsMsgSvc; 00009 ServiceHandle<IMessageSvc> msgh("MessageSvc","GaudiMessages"); 00010 gsMsgSvc = msgh.operator->(); 00011 return gsMsgSvc; 00012 } 00013 00014 00015 GaudiMsgStreams::GaudiMsgStreams(const std::string& streamName) 00016 : m_msgStream(msgSvc(),streamName) 00017 { 00018 00019 } 00020 00021 MsgStream& GaudiMsgStreams::log(MSG::Level level) 00022 { 00023 m_msgStream << level; 00024 return m_msgStream; 00025 } 00026 00027 MsgStream& GaudiMsgStreams::verbose() 00028 { 00029 return this->log(MSG::VERBOSE); 00030 } 00031 MsgStream& GaudiMsgStreams::debug() 00032 { 00033 return this->log(MSG::DEBUG); 00034 } 00035 MsgStream& GaudiMsgStreams::info() 00036 { 00037 return this->log(MSG::INFO); 00038 } 00039 MsgStream& GaudiMsgStreams::warning() 00040 { 00041 return this->log(MSG::WARNING); 00042 } 00043 MsgStream& GaudiMsgStreams::error() 00044 { 00045 return this->log(MSG::ERROR); 00046 } 00047 MsgStream& GaudiMsgStreams::fatal() 00048 { 00049 return this->log(MSG::FATAL); 00050 } 00051 MsgStream& GaudiMsgStreams::always() 00052 { 00053 return this->log(MSG::ALWAYS); 00054 } 00055 00056 00057 GaudiMessaging::GaudiMessaging(const std::string& streamName) 00058 : m_stream(streamName) 00059 { 00060 } 00061 00062 void GaudiMessaging::log(int ilevel, const std::string& msg) 00063 { 00064 MSG::Level level = (MSG::Level)ilevel; 00065 m_stream.log(level) << msg << endreq; 00066 } 00067 00068 void GaudiMessaging::verbose(const std::string& msg) 00069 { 00070 this->log(1,msg); 00071 } 00072 void GaudiMessaging::debug(const std::string& msg) 00073 { 00074 this->log(2,msg); 00075 } 00076 void GaudiMessaging::info(const std::string& msg) 00077 { 00078 this->log(3,msg); 00079 } 00080 void GaudiMessaging::warning(const std::string& msg) 00081 { 00082 this->log(4,msg); 00083 } 00084 void GaudiMessaging::error(const std::string& msg) 00085 { 00086 this->log(5,msg); 00087 } 00088 void GaudiMessaging::fatal(const std::string& msg) 00089 { 00090 this->log(6,msg); 00091 } 00092 void GaudiMessaging::always(const std::string& msg) 00093 { 00094 this->log(7,msg); 00095 } 00096 00097 void GaudiMessagesTest::test_info(std::string msg) 00098 { 00099 GaudiMsgStreams log("test_info"); 00100 log.info() << msg << endreq; 00101 }