1 //----------------------------------------------------------------------------- 2 // LogFile 3 //----------------------------------------------------------------------------- 4 5 #ifndef __LOGFILE_H__ 6 #define __LOGFILE_H__ 7 8 #include "definitions.h" 9 #include <stdio.h> 10 11 /** 12 * LogFile class. 13 * The logfile class is an interface to the log file. It is possible to save 14 * log data to this log file through methods of the log class. The log 15 * files can store messages from the system or the user. In fact, it store 16 * every console message and some other messages. 17 * The log file can be used for debug by reading the successive events that 18 * occured during engine execution. 19 * The log file content is replaced with new data, each time the engine is 20 * executed, so the log file stores only the last execution of the engine. 21 */ 22 class LogFile 23 { 24 private: 25 FILE* logfile; /**< logfile pointer */ 26 char outputfile[FILENAME_LENGTH]; /**< logfile name */ 27 bool startNewLine; 28 29 public: 30 LogFile(void); 31 ~LogFile(void); 32 33 /** 34 * Adds a line into the log file 35 * @param s the new line to write 36 */ 37 void Insert(const char* s, ...); 38 39 /** 40 * Opens the logfile for multiple insertions. 41 * This function can be used when multiple insertions in logfile has to be done. 42 * This should improve insertions speed. 43 * @return Logfile pointer if file could be opended, NULL pointer if not. 44 */ 45 FILE* OpenFile(void); 46 47 /** 48 * Closes the logfile after multiple insertions. 49 * @return 0 if the stream is successfully closed. 50 */ 51 int CloseFile(void); 52 }; 53 54 #endif /* __LOGFILE_H__ */ 55