48 LogManager* LogManager::m_instance = NULL;
78 if (level < m_level) {
81 if (!isVisible(module)) {
84 std::string lvlstr =
"";
86 case LEVEL_DEBUG: lvlstr =
"DEBUG";
89 case LEVEL_LOG: lvlstr =
"LOG";
92 case LEVEL_WARN: lvlstr =
"WARN";
95 case LEVEL_ERROR: lvlstr =
"ERROR";
98 case LEVEL_PANIC: lvlstr =
"PANIC";
101 default: lvlstr =
"ERROR";
105 std::cout << moduleInfos[module].name <<
":" << lvlstr <<
":" << msg << std::endl;
108 *m_logfile << moduleInfos[module].name <<
":" << lvlstr <<
":" << msg << std::endl;
110 if (level == LEVEL_PANIC) {
124 validateModule(module);
125 int32_t ind =
static_cast<int32_t
>(module);
126 m_modules[ind] =
true;
127 if (moduleInfos[ind].parent !=
LM_CORE) {
128 addVisibleModule(moduleInfos[ind].parent);
133 validateModule(module);
134 m_modules[module] =
false;
139 m_modules[i] =
false;
144 m_logtoprompt = logtoprompt;
148 return m_logtoprompt;
153 m_logfile =
new std::ofstream(
"fife.log");
160 m_logtofile = logtofile;
168 if (!m_modules[module]) {
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,.
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.
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.
LogLevel
Loglevel is used to set a treshold for output messages + related filter E.g.