00001 #ifndef MSGHANDLERSTDSTREAMS_HH 00002 #define MSGHANDLERSTDSTREAMS_HH 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: MsgHandlerStdStreams.h 2700 2011-12-09 21:52:07Z salnikov@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class MsgHandlerStdStreams. 00010 // 00011 // Environment: 00012 // This software was developed for the BaBar collaboration. If you 00013 // use all or part of it, please give an appropriate acknowledgement. 00014 // 00015 // Author List: 00016 // Andy Salnikov 00017 // 00018 // Copyright Information: 00019 // Copyright (C) 2005 SLAC 00020 // 00021 //------------------------------------------------------------------------ 00022 00023 //------------- 00024 // C Headers -- 00025 //------------- 00026 extern "C" { 00027 } 00028 00029 //--------------- 00030 // C++ Headers -- 00031 //--------------- 00032 #include <iostream> 00033 #include <string> 00034 #include <boost/thread/mutex.hpp> 00035 00036 //---------------------- 00037 // Base Class Headers -- 00038 //---------------------- 00039 #include "MsgLogger/MsgHandler.h" 00040 00041 //------------------------------- 00042 // Collaborating Class Headers -- 00043 //------------------------------- 00044 00045 //------------------------------------ 00046 // Collaborating Class Declarations -- 00047 //------------------------------------ 00048 00049 // --------------------- 00050 // -- Class Interface -- 00051 // --------------------- 00052 00053 namespace MsgLogger { 00054 00055 class MsgLogLevel ; 00056 00057 /// @addtogroup MsgLogger_detail 00058 00059 /** 00060 * @ingroup MsgLogger_detail 00061 * 00062 * Implementation of the message handler which logs formatted messages to 00063 * the stanfard C++ streams cout and cerr (well I have removed "error" 00064 * levels so it's only logs to cout now.) 00065 * 00066 * This software was developed for the BaBar collaboration. If you 00067 * use all or part of it, please give an appropriate acknowledgement. 00068 * 00069 * Copyright (C) 2005 SLAC 00070 * 00071 * @see MsgHandlerStdStreamsMsgHandlerStdStreams 00072 * 00073 * @version $Id: MsgHandlerStdStreams.h 2700 2011-12-09 21:52:07Z salnikov@SLAC.STANFORD.EDU $ 00074 * 00075 * @author Andy Salnikov 00076 */ 00077 00078 class MsgHandlerStdStreams : public MsgHandler { 00079 00080 public: 00081 00082 // Constructor 00083 MsgHandlerStdStreams() ; 00084 00085 // Destructor 00086 virtual ~MsgHandlerStdStreams() ; 00087 00088 /// get the stream for the specified log level 00089 virtual bool log ( const MsgLogRecord& record ) const ; 00090 00091 protected: 00092 00093 private: 00094 00095 mutable boost::mutex m_mutex ; 00096 00097 // Disable copy 00098 MsgHandlerStdStreams( const MsgHandlerStdStreams& ); 00099 MsgHandlerStdStreams& operator= ( const MsgHandlerStdStreams& ); 00100 00101 }; 00102 } // namespace MsgLogger 00103 00104 #endif // MSGHANDLERSTDSTREAMS_HH