44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef _LOGGING_H
|
|
#define _LOGGING_H
|
|
|
|
#include "Engine.h"
|
|
|
|
namespace Engine {
|
|
|
|
class Module;
|
|
|
|
/** \brief All logging goes through this class
|
|
*
|
|
* Only log messages higher or equal that of mPrintLevel are printed out. When
|
|
* a log filename was specified by Logging::SetLogFilename() then all messages
|
|
* sent to the Logging class are written to the file.
|
|
*
|
|
* \TODO Add log level for files separately
|
|
*/
|
|
class Logging : public Module {
|
|
public:
|
|
void Log (LogLevel level, const char *str, ...);
|
|
void SetLogPrintLevel (LogLevel print_level);
|
|
void SetLogFilename (const char *filename);
|
|
/** \brief Returns the last LogEntry that was sent to the Logging module
|
|
*/
|
|
const LogEntry& GetLastEntry ();
|
|
|
|
protected:
|
|
/** \brief Initializes the system */
|
|
virtual int OnInit (int argc, char* argv[]);
|
|
/** \brief Destroys the system (must be called!) */
|
|
virtual void OnDestroy ();
|
|
|
|
private:
|
|
LogLevel mPrintLevel;
|
|
/** \brief Stores all log messages that were sent to the Logging module
|
|
* \todo Restrict the number of entries to be stored!
|
|
*/
|
|
std::vector<LogEntry> mLogEntries;
|
|
std::ofstream mLogFileOut;
|
|
};
|
|
|
|
}
|
|
#endif // _LOGGING_H
|