src/Logger.h

00001 #ifndef LOGGER_H_
00002 #define LOGGER_H_
00003 
00004 #include <iostream>
00005 #include <iosfwd>
00006 #include <fstream>
00007 #include <sstream>
00008 #include <iomanip>
00009 
00010 #include "SDL.h"
00011 
00012 //Log modes
00013 #define LOGMODE_NORMAL (1)      
00014 #define LOGMODE_ERROR (2)       
00015 #define LOGMODE_AUTH (3)        
00016 #define LOGMODE_DB (4)      
00018 //Define the paths of previously defined log-modes.
00019 #define LOGFILE_NORMAL "log/log"
00020 #define LOGFILE_ERROR "log/error-log"
00021 #define LOGFILE_AUTH "log/auth-log"
00022 #define LOGFILE_DB "log/db-log"
00023 
00029 class Logger
00030 {
00031 protected:
00035         Logger();
00036 
00040         virtual ~Logger();
00041 
00042 private:
00043 
00044         static Logger* pUniqueInstance; 
00045         static SDL_mutex* mxInstance;   
00047 public:
00057         static Logger* getInstance();
00058 
00065         static void freeInstance();
00066 
00075         void setDebugMode(bool flag = true);
00076 
00085         void log(const std::string &msg, Uint16 mode);
00086 
00094          std::string getCurrentTime();
00095 
00096 private:
00097         /*
00098          * @todo stonedz: I would like to use a stream's vector or a stream's map
00099          * in order to be able to register as many logfiles as we want, even during
00100          * runtime.
00101          */
00102         std::ofstream LogFile;          
00103         std::ofstream ErrLogFile;       
00104         std::ofstream AuthLogFile;      
00105         std::ofstream DBLogFile;    
00107         SDL_mutex* mxStdLogger;     
00108         SDL_mutex* mxErrLogger;     
00109         SDL_mutex* mxAuthLogger;    
00110     SDL_mutex* mxDBLogger;       
00112         SDL_mutex* mxLoggerProp;    
00120         bool debugMode;
00121 };
00122 
00123 #endif /*LOGGER_H_*/

Generated on Mon Dec 3 04:30:13 2007 for lo-testserver by  doxygen 1.3.9.1