00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_DISPLAYER_H
00027 #define NL_DISPLAYER_H
00028
00029 #include "nel/misc/types_nl.h"
00030
00031 #include <string>
00032
00033 #include "nel/misc/log.h"
00034
00035 namespace NLMISC
00036 {
00037
00038
00039
00040 struct TDisplayInfo
00041 {
00042 TDisplayInfo() : Date(0), LogType(CLog::LOG_NO), ThreadId(0), Filename(NULL), Line(-1) {}
00043
00044 time_t Date;
00045 CLog::TLogType LogType;
00046 std::string ProcessName;
00047 uint ThreadId;
00048 const char *Filename;
00049 sint Line;
00050
00051 std::string CallstackAndLog;
00052 };
00053
00054
00055 class CMutex;
00056
00057
00065 class IDisplayer
00066 {
00067 public:
00068
00070 IDisplayer(const char *displayerName = "");
00071
00073 virtual ~IDisplayer();
00074
00076 void display( const TDisplayInfo& args, const char *message );
00077
00079 std::string DisplayerName;
00080
00081 protected:
00082
00084 virtual void doDisplay( const TDisplayInfo& args, const char *message) = 0;
00085
00086
00088 static const char *logTypeToString (CLog::TLogType logType, bool longFormat = false);
00089
00091 static const char *IDisplayer::dateToHumanString ();
00092
00094 static const char *dateToHumanString (time_t date);
00095
00097 static const char *dateToComputerString (time_t date);
00098
00099
00100 static const char *HeaderString ();
00101
00102 private:
00103
00104 CMutex *_Mutex;
00105 };
00106
00107
00108
00116 class CStdDisplayer : virtual public IDisplayer
00117 {
00118 public:
00119 CStdDisplayer (const char *displayerName = "") : IDisplayer (displayerName) {}
00120
00121 protected:
00122
00124 virtual void doDisplay ( const TDisplayInfo& args, const char *message );
00125 };
00126
00127
00135 class CFileDisplayer : virtual public IDisplayer
00136 {
00137 public:
00138
00140 CFileDisplayer (const std::string &filename, bool eraseLastLog = false, const char *displayerName = "");
00141
00142 CFileDisplayer ();
00143
00145 void setParam (const std::string &filename, bool eraseLastLog = false);
00146
00147 protected:
00149 virtual void doDisplay ( const TDisplayInfo& args, const char *message );
00150
00151 private:
00152 std::string _FileName;
00153
00154 FILE *_FilePointer;
00155
00156 bool _NeedHeader;
00157 };
00158
00166 class CMsgBoxDisplayer : virtual public IDisplayer
00167 {
00168 public:
00169 CMsgBoxDisplayer (const char *displayerName = "") : IDisplayer (displayerName), IgnoreNextTime(false) {}
00170
00171 bool IgnoreNextTime;
00172
00173 protected:
00175 virtual void doDisplay ( const TDisplayInfo& args, const char *message );
00176 };
00177
00178
00179 };
00180
00181 #endif // NL_DISPLAYER_H
00182
00183