# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

log.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_LOG_H
00027 #define NL_LOG_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/mutex.h"
00031 
00032 #include <string>
00033 #include <list>
00034 
00035 
00036 namespace NLMISC
00037 {
00038 
00039 class IDisplayer;
00040 
00053 class CLog {
00054 public:
00055 
00056         typedef enum { LOG_NO=0, LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG, LOG_STAT, LOG_ASSERT, LOG_UNKNOWN } TLogType;
00057 
00058         CLog(TLogType logType = LOG_NO);
00059 
00063         void addDisplayer (IDisplayer *displayer, bool bypassFilter = false);
00064 
00066         IDisplayer *getDisplayer (const char *displayerName);
00067 
00069         void removeDisplayer (IDisplayer *displayer);
00070 
00072         void removeDisplayer (const char *displayerName);
00073 
00075         bool attached(IDisplayer *displayer) const;
00076         
00078         bool noDisplayer() const { return _Displayers.empty() && _BypassFilterDisplayers.empty(); }
00079 
00080 
00082         static void setProcessName (const std::string &processName);
00083 
00085         static void setDefaultProcessName ();
00086 
00088         void setPosition (sint line, char *fileName);
00089 
00090 
00092         void displayNL (const char *format, ...);
00093 
00095         void display (const char *format, ...);
00096 
00098         void displayRawNL (const char *format, ...);
00099 
00101         void displayRaw (const char *format, ...);
00102 
00105         void forceDisplayRaw (const char *format, ...);
00106         
00108         void addPositiveFilter( const char *filterstr );
00109 
00111         void addNegativeFilter( const char *filterstr );
00112 
00114         void resetFilters();
00115 
00117         void removeFilter( const char *filterstr = NULL);
00118 
00120         void displayFilter( CLog &log );
00121 
00122 protected:
00123 
00125         void unsetPosition();
00126 
00128         bool passFilter( const char *filter );
00129 
00130         TLogType                          _LogType;
00131         static std::string                        *_ProcessName;
00132 
00133         sint                              _Line;
00134         char                             *_FileName;
00135 
00136         typedef std::list<IDisplayer *> CDisplayers;
00137 
00138         CDisplayers                       _Displayers;
00139 
00140         CDisplayers                       _BypassFilterDisplayers;      // these displayers always log info (by pass filter system)
00141 
00142         CMutex                                                    _Mutex;
00143 
00144         uint32                                                    _PosSet;
00145 
00147         std::list<std::string>                    _NegativeFilter;
00148 
00150         std::list<std::string>                    _PositiveFilter;
00151 
00153         void displayString (const char *str);
00154 
00156         void displayRawString (const char *str);
00157 
00158 };
00159 
00160 
00161 } // NLMISC
00162 
00163 #endif // NL_LOG_H
00164 
00165 /* End of log.h */