FIFE
|
Logmanager takes care of log filtering and output direction. More...
#include <logger.h>
Public Types | |
enum | LogLevel { LEVEL_DEBUG = 0, LEVEL_LOG = 1, LEVEL_WARN = 2, LEVEL_ERROR = 3, LEVEL_PANIC = 4 } |
Loglevel is used to set a treshold for output messages + related filter E.g. More... | |
Public Member Functions | |
~LogManager () | |
Destructor. More... | |
void | log (LogLevel level, logmodule_t module, const std::string &msg) |
Logs given message. More... | |
void | setLevelFilter (LogLevel level) |
Sets currently used level filter. More... | |
LogLevel | getLevelFilter () |
Gets currently used level filter. More... | |
void | addVisibleModule (logmodule_t module) |
Adds visible module into logmanager Module corresponds some module in the engine. More... | |
void | removeVisibleModule (logmodule_t module) |
Removes visible module,. More... | |
void | clearVisibleModules () |
Removes all visible modules,. More... | |
bool | isVisible (logmodule_t module) |
Tells if given module is visible. More... | |
void | setLogToPrompt (bool logtoprompt) |
Sets LogManager to log to prompt. More... | |
bool | isLogToPrompt () |
Returns if LogManager is set to log to prompt. More... | |
void | setLogToFile (bool logtofile) |
Sets LogManager to log to a file. More... | |
bool | isLogToFile () |
Returns if LogManager is set to log to a file. More... | |
std::string | getModuleName (logmodule_t module) |
Gets display name for given module id E.g. More... | |
Static Public Member Functions | |
static LogManager * | instance () |
Returns instance to log manager. More... | |
Private Member Functions | |
void | validateModule (logmodule_t m) |
LogManager () | |
void | validateModuleDescription (logmodule_t module) |
Private Attributes | |
LogLevel | m_level |
bool | m_modules [LM_MODULE_MAX] |
std::vector< logmodule_t > | module_check_stack |
bool | m_logtofile |
bool | m_logtoprompt |
std::ofstream * | m_logfile |
Static Private Attributes | |
static LogManager * | m_instance = NULL |
Logmanager takes care of log filtering and output direction.
FIFE::LogManager::~LogManager | ( | ) |
|
private |
Definition at line 177 of file logger.cpp.
References clearVisibleModules(), LM_CORE, m_logfile, and validateModuleDescription().
Referenced by instance().
void FIFE::LogManager::addVisibleModule | ( | logmodule_t | module | ) |
Adds visible module into logmanager Module corresponds some module in the engine.
Modules may contain other modules. Modules and their structure is defined in file modules.h. In case module is not visible, LogManager filters corresponding log messages from output. In case some lower-level module is set visible, it also sets all upper level modules visible
module | module to set visible |
Definition at line 123 of file logger.cpp.
References LM_CORE, m_modules, and validateModule().
void FIFE::LogManager::clearVisibleModules | ( | ) |
Removes all visible modules,.
Definition at line 137 of file logger.cpp.
References LM_MODULE_MAX, and m_modules.
Referenced by LogManager().
LogManager::LogLevel FIFE::LogManager::getLevelFilter | ( | ) |
Gets currently used level filter.
Definition at line 119 of file logger.cpp.
References m_level.
std::string FIFE::LogManager::getModuleName | ( | logmodule_t | module | ) |
Gets display name for given module id E.g.
LM_AUDIO -> "Audio"
Definition at line 216 of file logger.cpp.
|
static |
Returns instance to log manager.
Log manager is a singleton class
Definition at line 65 of file logger.cpp.
References LogManager(), and m_instance.
Referenced by FIFE::Engine::Engine(), and FIFE::Logger::log().
bool FIFE::LogManager::isLogToFile | ( | ) |
Returns if LogManager is set to log to a file.
Definition at line 163 of file logger.cpp.
References m_logtofile.
bool FIFE::LogManager::isLogToPrompt | ( | ) |
Returns if LogManager is set to log to prompt.
Definition at line 147 of file logger.cpp.
References m_logtoprompt.
bool FIFE::LogManager::isVisible | ( | logmodule_t | module | ) |
Tells if given module is visible.
Definition at line 167 of file logger.cpp.
References LM_CORE, and m_modules.
Referenced by log().
void FIFE::LogManager::log | ( | LogLevel | level, |
logmodule_t | module, | ||
const std::string & | msg | ||
) |
Logs given message.
level | level of this log (e.g. warning) |
module | module where this log message is coming from. Modules are defined in modules.h-file |
msg | message to log |
Definition at line 77 of file logger.cpp.
References isVisible(), LEVEL_DEBUG, LEVEL_ERROR, LEVEL_LOG, LEVEL_PANIC, LEVEL_WARN, m_level, m_logfile, m_logtofile, and m_logtoprompt.
Referenced by FIFE::Logger::log().
void FIFE::LogManager::removeVisibleModule | ( | logmodule_t | module | ) |
Removes visible module,.
Definition at line 132 of file logger.cpp.
References m_modules, and validateModule().
void FIFE::LogManager::setLevelFilter | ( | LogLevel | level | ) |
Sets currently used level filter.
For usage,
Definition at line 115 of file logger.cpp.
References m_level.
void FIFE::LogManager::setLogToFile | ( | bool | logtofile | ) |
Sets LogManager to log to a file.
Definition at line 151 of file logger.cpp.
References m_logfile, and m_logtofile.
void FIFE::LogManager::setLogToPrompt | ( | bool | logtoprompt | ) |
Sets LogManager to log to prompt.
Definition at line 143 of file logger.cpp.
References m_logtoprompt.
|
private |
Definition at line 187 of file logger.cpp.
References LM_CORE, and LM_MODULE_MAX.
Referenced by addVisibleModule(), and removeVisibleModule().
|
private |
Definition at line 194 of file logger.cpp.
References LM_CORE, LM_MODULE_MAX, and module_check_stack.
Referenced by LogManager().
|
staticprivate |
Definition at line 191 of file logger.h.
Referenced by instance(), and ~LogManager().
|
private |
Definition at line 193 of file logger.h.
Referenced by getLevelFilter(), log(), and setLevelFilter().
|
private |
Definition at line 202 of file logger.h.
Referenced by log(), LogManager(), and setLogToFile().
|
private |
Definition at line 199 of file logger.h.
Referenced by isLogToFile(), log(), and setLogToFile().
|
private |
Definition at line 200 of file logger.h.
Referenced by isLogToPrompt(), log(), and setLogToPrompt().
|
private |
Definition at line 195 of file logger.h.
Referenced by addVisibleModule(), clearVisibleModules(), isVisible(), and removeVisibleModule().
|
private |
Definition at line 197 of file logger.h.
Referenced by validateModuleDescription().