# 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  

displayer.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_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 // Debug information
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;        // contains the callstack and a log with not filter of N last line (only in error/assert log type)
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         // Return the header string with date (for the first line of the log)
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 /* End of displayer.h */