Claw
1.7.3
|
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-2011 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@gamned.org 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 CLAW_LOGGER_NO_EXPORT 00042 # define CLAW_LOGGER_EXPORT 00043 # else 00044 # ifdef _WIN32 00045 # ifdef claw_logger_EXPORTS 00046 # define CLAW_LOGGER_EXPORT __declspec(dllexport) 00047 # else 00048 # define CLAW_LOGGER_EXPORT __declspec(dllimport) 00049 # endif // def claw_logger_EXPORTS 00050 # else // def _WIN32 00051 # define CLAW_LOGGER_EXPORT 00052 # endif // def _WIN32 00053 # endif // def CLAW_LOGGER_NO_EXPORT 00054 #endif // ndef CLAW_LOGGER_EXPORT 00055 00056 namespace claw 00057 { 00071 class log_system 00072 { 00073 public: 00074 typedef log_stream stream_type; 00075 typedef std::list<stream_type*> stream_list_type; 00076 00077 public: 00078 CLAW_LOGGER_EXPORT log_system(); 00079 CLAW_LOGGER_EXPORT ~log_system(); 00080 CLAW_LOGGER_EXPORT void clear(); 00081 00082 CLAW_LOGGER_EXPORT void merge( stream_type* s ); 00083 CLAW_LOGGER_EXPORT void remove( const stream_type* s ); 00084 CLAW_LOGGER_EXPORT void set( stream_type* s ); 00085 CLAW_LOGGER_EXPORT void set_level( int lvl ); 00086 CLAW_LOGGER_EXPORT void set_level( const log_level& lvl ); 00087 00088 CLAW_LOGGER_EXPORT void flush(); 00089 00090 template<typename T> 00091 log_system& operator<<( const T& that ); 00092 00093 CLAW_LOGGER_EXPORT log_system& operator<<( const log_level& that ); 00094 CLAW_LOGGER_EXPORT log_system& operator<<( log_system& (*pf)(log_system&) ); 00095 00096 private: 00099 int m_log_level; 00100 00102 int m_message_level; 00103 00105 stream_list_type m_stream; 00106 00107 }; // class log_system 00108 00109 CLAW_LOGGER_EXPORT extern log_system logger; 00110 00111 CLAW_LOGGER_EXPORT log_system& lendl(log_system& log); 00112 00113 } // namespace claw 00114 00115 namespace std 00116 { 00117 CLAW_LOGGER_EXPORT claw::log_system& endl( claw::log_system& log ); 00118 } // namespace std 00119 00120 // template methods 00121 #include <claw/impl/logger.tpp> 00122 00123 #endif // __CLAW_LOGGER_HPP__