logger.h

Go to the documentation of this file.
00001 /* Logging everything.
00002  *
00003  * PegSoft log subsystem library (c) 2005 PegSoft
00004  * Contact us at pegsoft@pegsoft.net
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License version 2 as
00008  * published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software (the COPYING file); if not, write to the
00017  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
00018  * USA.
00019  *
00020  */
00021 
00027 #ifndef LOG_LOGGER_H
00028 #define LOG_LOGGER_H
00029 
00030 /*************************************************************************/
00031 
00032 #include <list>
00033 
00034 /*************************************************************************/
00035 
00036 namespace modules { class Core; }
00037 
00038 /*************************************************************************/
00039 
00040 namespace xlog
00041 {
00042 
00043 /*************************************************************************/
00044 
00045 class Log;
00046 class LogLevel;
00047 class LogRules;
00048 
00049 /*************************************************************************/
00050 
00052 
00057 class Logger
00058 {
00059     public:
00061         typedef std::list<Log *> container_type;
00062         
00064         static int const msg_length = 2048;
00065         
00067 
00073         explicit Logger(modules::Core &core, LogRules const &rules) :
00074                 m_core(&core), m_interfaces(), m_rules(&rules) { }
00076         Logger (Logger const &l) : m_core(l.m_core),
00077                 m_interfaces(l.m_interfaces), m_rules(l.m_rules) { }
00079         Logger &operator=(Logger const &right);
00080         
00082 
00090         void log(LogLevel const &level, char const *format, ...)
00091                 FORMAT(printf, 3, 4);
00092         
00094 
00102         void register_interface(Log &interface);
00103         
00105 
00109         void unregister_interface(Log &interface);
00110         
00112         void vlog(LogLevel const &level, char const *format,
00113                 va_list args);
00114     private:
00115         modules::Core *m_core;
00116         container_type m_interfaces;
00117         LogRules const *m_rules;
00118 };
00119 
00120 /*************************************************************************/
00121 
00122 } /* namespace xlog */
00123 
00124 /*************************************************************************/
00125 
00126 #endif /* LOG_LOGGER_H */

Generated on Fri Apr 18 22:03:27 2008 for Epona API by  doxygen 1.5.3