84 std::string lvlstr =
"";
101 default: lvlstr =
"ERROR";
105 std::cout << moduleInfos[module].name <<
":" << lvlstr <<
":" << msg << std::endl;
108 *
m_logfile << moduleInfos[module].name <<
":" << lvlstr <<
":" << msg << std::endl;
125 int32_t ind =
static_cast<int32_t
>(module);
127 if (moduleInfos[ind].parent !=
LM_CORE) {
153 m_logfile =
new std::ofstream(
"fife.log");
171 if (moduleInfos[module].parent !=
LM_CORE) {
172 return isVisible(moduleInfos[module].parent);
178 m_level(LEVEL_DEBUG),
179 module_check_stack(),
181 m_logtoprompt(false) {
189 std::cout <<
"Invalid module received in LogManager: " << m <<
", aborting\n";
196 for (int32_t m = static_cast<int32_t>(
LM_CORE)+1; m < static_cast<int32_t>(
LM_MODULE_MAX); m++) {
197 if (moduleInfos[m].module != static_cast<logmodule_t>(m)) {
198 std::ostringstream stream;
200 std::string msg =
"Log module definition ids do not match in index ";
202 std::cout << msg << std::endl;
203 throw InvalidFormat(msg);
211 throw InvalidFormat(
"Log module definition hierarchy contains cycles");
217 return moduleInfos[module].name;
void validateModule(logmodule_t m)
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
void setLogToFile(bool logtofile)
Sets LogManager to log to a file.
void validateModuleDescription(logmodule_t module)
void log(LogManager::LogLevel level, const std::string &msg)
logs given message with given log level
void clearVisibleModules()
Removes all visible modules,.
void addVisibleModule(logmodule_t module)
Adds visible module into logmanager Module corresponds some module in the engine. ...
std::vector< logmodule_t > module_check_stack
void log(LogLevel level, logmodule_t module, const std::string &msg)
Logs given message.
std::ofstream * m_logfile
logmodule_t
Modules available for logging.
LogLevel getLevelFilter()
Gets currently used level filter.
bool isVisible(logmodule_t module)
Tells if given module is visible.
static LogManager * instance()
Returns instance to log manager.
bool isLogToFile()
Returns if LogManager is set to log to a file.
void removeVisibleModule(logmodule_t module)
Removes visible module,.
Logger(logmodule_t module)
Creates new logger and associates it with given module.
std::string getModuleName(logmodule_t module)
Gets display name for given module id E.g.
Logmanager takes care of log filtering and output direction.
bool isLogToPrompt()
Returns if LogManager is set to log to prompt.
bool m_modules[LM_MODULE_MAX]
void setLogToPrompt(bool logtoprompt)
Sets LogManager to log to prompt.
#define MODULE_INFO_RELATIONSHIPS
Module hierarchy definition + display strings format = module, module parent, module display name...
void setLevelFilter(LogLevel level)
Sets currently used level filter.
static LogManager * m_instance
LogLevel
Loglevel is used to set a treshold for output messages + related filter E.g.