NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
EventLogger.h
Go to the documentation of this file.
00001 
00009 #pragma once
00010 
00011 
00012 // Standard Includes
00013 #include <queue>
00014 #include <string>
00015 
00016 // Library Includes
00017 #include <threading.h>
00018 
00019 // Local Includes
00020 
00021 // Forward Declarations
00022 
00023 // Typedefs
00024 
00025 // Macro to make messages more meaningful
00027 #define LOG(x, y) ::EventLogger::GetEventLogger()->LogToDisk((x), (y), __FILE__, __LINE__, __FUNCTION__);
00028 
00029 #define LOG2(x, y) {if (this->debug_output) {::EventLogger::GetEventLogger()->LogToDisk((x), (y), __FILE__, __LINE__, __FUNCTION__);}}
00030 
00032 namespace LOG_PRIORITY {
00034   enum TYPE {
00035     INFO = 0, 
00036     FLOW = 1, 
00037     
00038     WARN = 2, 
00039     
00040     CONFIG   = 3, 
00041     ERR      = 4, 
00042     MISSRESS = 5, 
00043     RESTART  = 6, 
00044     SYSERR   = 7, 
00045     
00046     DEPRICATE = 8, 
00047     
00048     ENUM_COUNT
00049   };
00050   
00052   static const std::string PRINTABLE_NOTICES[ENUM_COUNT] = {
00053     "INFORMATION", // 0
00054     "PROGRAMFLOW", // 1
00055     "WARNING    ", // 2
00056     "BADCONFIG  ", // 3
00057     "ERROR      ", // 4
00058     "MISSINGRESS", // 5
00059     "RESTART/SET", // 6
00060     "SYSTEMERROR", // 7
00061     "DEPRICATED " // 8
00062   };
00063 }
00064 
00065 class EventLogger {
00066 public: // Public static members
00067   static void SetEventLogger(EventLogger*);
00068   static EventLogger* GetEventLogger();
00069   
00070 public: // Public static parameters
00071   static std::string module;
00072   
00073 public: // Public members
00074   ~EventLogger(void);
00075   
00078   bool PrintToFile(unsigned int entryPriorityLevel, std::string text, char const* file = "NOFILE.cpp", int line = 0, char const* func = "void()") { return LogToDisk(LOG_PRIORITY::TYPE(entryPriorityLevel), text, file, (unsigned int) line, func); }
00079   
00081   bool LogToDisk(const LOG_PRIORITY::TYPE&, const std::string&, const std::string& = "<NO FILE>", const unsigned int& = 0, const std::string& = "<NO FUNCTION>");
00082   
00084   bool SetLogFile(const std::string&);
00085   
00086 private: // Private members
00087   EventLogger(void);
00088   
00089 private: // Private static properties
00090   static EventLogger* glogger;
00091   
00092 private: // Private properties
00093   Threading::ReadWriteMutex mutex;
00094   std::queue<std::string> logQueue;
00095   std::string logFile;
00096 };