00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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;
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 }
00162
00163 #endif // NL_LOG_H
00164
00165