![]() |
Dragonfly 2.2
A text-based game engine
|
00001 /// 00002 /// The log manager 00003 /// 00004 00005 #ifndef __LOG_MANAGER_H__ 00006 #define __LOG_MANAGER_H__ 00007 00008 #include "Manager.h" 00009 #include "utility.h" 00010 00011 #define LOGFILE_NAME "dragonfly.log" 00012 00013 class LogManager : public Manager { 00014 00015 private: 00016 LogManager(); ///< Private since a singleton. 00017 LogManager (LogManager const&); ///< Don't allow copy. 00018 void operator=(LogManager const&); ///< Don't allow assignment. 00019 00020 protected: 00021 bool do_flush; ///< True if fflush after each write. 00022 FILE *fp; ///< Pointer to log file. 00023 00024 public: 00025 ~LogManager(); 00026 00027 /// Get the one and only instance of the LogManager. 00028 static LogManager &getInstance(); 00029 00030 /// Start up the LogManager (open logfile "dragonfly.log"). 00031 /// if flush is true, then call fflush() afer each write. 00032 int startUp(bool flush=false); 00033 00034 /// Shut down the LogManager (close logfile). 00035 void shutDown(); 00036 00037 /// \brief Write to logfile. 00038 /// Supports printf() formatting of strings. 00039 /// Return number of bytes written, -1 if error. 00040 int writeLog(const char *fmt, ...); 00041 }; 00042 00043 #endif // __LOG_MANAGER_H__