00001 /* 00002 CLAW - a C++ Library Absolutely Wonderful 00003 00004 CLAW is a free library without any particular aim but being useful to 00005 anyone. 00006 00007 Copyright (C) 2005-2008 Julien Jorge 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 contact: julien_jorge@yahoo.fr 00024 */ 00030 #ifndef __CLAW_LOGGER_HPP__ 00031 #define __CLAW_LOGGER_HPP__ 00032 00033 #include <ostream> 00034 #include <list> 00035 #include <string> 00036 00037 #include <claw/log_level.hpp> 00038 #include <claw/log_stream.hpp> 00039 00040 #ifndef CLAW_LOGGER_EXPORT 00041 # ifdef _WIN32 00042 # ifdef claw_logger_EXPORTS 00043 # define CLAW_LOGGER_EXPORT __declspec(dllexport) 00044 # else 00045 # define CLAW_LOGGER_EXPORT __declspec(dllimport) 00046 # endif // def claw_logger_EXPORTS 00047 # else // def _WIN32 00048 # define CLAW_LOGGER_EXPORT 00049 # endif // def _WIN32 00050 #endif // ndef CLAW_LOGGER_EXPORT 00051 00052 namespace claw 00053 { 00067 class log_system 00068 { 00069 public: 00070 typedef log_stream stream_type; 00071 typedef std::list<stream_type*> stream_list_type; 00072 00073 public: 00074 CLAW_LOGGER_EXPORT log_system(); 00075 CLAW_LOGGER_EXPORT ~log_system(); 00076 CLAW_LOGGER_EXPORT void clear(); 00077 00078 CLAW_LOGGER_EXPORT void merge( stream_type* s ); 00079 CLAW_LOGGER_EXPORT void remove( const stream_type* s ); 00080 CLAW_LOGGER_EXPORT void set( stream_type* s ); 00081 CLAW_LOGGER_EXPORT void set_level( int lvl ); 00082 CLAW_LOGGER_EXPORT void set_level( const log_level& lvl ); 00083 00084 CLAW_LOGGER_EXPORT void flush(); 00085 00086 template<typename T> 00087 log_system& operator<<( const T& that ); 00088 00089 CLAW_LOGGER_EXPORT log_system& operator<<( const log_level& that ); 00090 CLAW_LOGGER_EXPORT log_system& operator<<( log_system& (*pf)(log_system&) ); 00091 00092 private: 00095 int m_log_level; 00096 00098 int m_message_level; 00099 00101 stream_list_type m_stream; 00102 00103 }; // class log_system 00104 00105 CLAW_LOGGER_EXPORT extern log_system logger; 00106 00107 CLAW_LOGGER_EXPORT log_system& lendl(log_system& log); 00108 00109 } // namespace claw 00110 00111 namespace std 00112 { 00113 CLAW_LOGGER_EXPORT claw::log_system& endl( claw::log_system& log ); 00114 } // namespace std 00115 00116 // template methods 00117 #include <claw/impl/logger.tpp> 00118 00119 #endif // __CLAW_LOGGER_HPP__