void operator()(std::string const& msg) const { #ifdef NLOG std::cerr << logname << ": " << msg << '\n'; #else LOG4CXX_LOG(plog, plevel, msg); #endif }
//------------------------------------------------------------------------------------- void DebugHelper::script_msg(const std::string& s) { KBEngine::thread::ThreadGuard tg(&this->logMutex); if(s.size() > 33 /* strlen("Traceback (most recent call last)" */) { if(s[0] == 'T' && s[10] == '(') { if(s.substr(0, 33) == "Traceback (most recent call last)") setScriptMsgType(log4cxx::ScriptLevel::SCRIPT_ERR); } } #ifdef NO_USE_LOG4CXX #else if(canLogFile_) LOG4CXX_LOG(g_logger, log4cxx::ScriptLevel::toLevel(scriptMsgType_), s); #endif onMessage(KBELOG_SCRIPT, s.c_str(), s.size()); #if KBE_PLATFORM == PLATFORM_WIN32 if(log4cxx::ScriptLevel::SCRIPT_ERR == scriptMsgType_) printf("[S_ERROR]: %s", s.c_str()); #endif }
//------------------------------------------------------------------------------------- void DebugHelper::script_msg(std::string s) { KBEngine::thread::ThreadGuard tg(&this->logMutex); #ifdef NO_USE_LOG4CXX #else LOG4CXX_LOG(g_logger, log4cxx::ScriptLevel::toLevel(scriptMsgType_), s); #endif onMessage(KBELOG_SCRIPT, s.c_str(), s.size()); #if KBE_PLATFORM == PLATFORM_WIN32 if(log4cxx::ScriptLevel::SCRIPT_ERR == scriptMsgType_) printf("[S_ERROR]: %s", s.c_str()); #endif }
//------------------------------------------------------------------------------------- void DebugHelper::script_msg(const char * info, ...) { if(info == NULL) return; KBEngine::thread::ThreadGuard tg(&this->logMutex); #ifdef NO_USE_LOG4CXX #else va_list ap; va_start(ap, info); #if KBE_PLATFORM == PLATFORM_WIN32 uint32 size = _vsnprintf(_g_buf, DBG_PT_SIZE, info, ap); #else uint32 size = vsnprintf(_g_buf, DBG_PT_SIZE, info, ap); #endif va_end(ap); LOG4CXX_LOG(g_logger, log4cxx::ScriptLevel::getScript(), _g_buf); #endif onMessage(LOG_SCRIPT, _g_buf, size); }
void LoggerWrapper::log(const uint32 id, const std::wstring& file, const uint32 line, std::wstring& message) { StringTable::log_id log_id = static_cast<StringTable::log_id>(id); BOOST_ASSERT(mStringTable->attribute_table.find(log_id) != mStringTable->attribute_table.end() && "Given wrong Log ID"); StringTable::attribute_table_t& attribute_table = mStringTable->attribute_table[log_id]; // Decide the level log4cxx::LevelPtr level; switch (attribute_table.level) { case StringTable::LEVEL_INFO: { level = log4cxx::Level::getInfo(); break; } case StringTable::LEVEL_WARNING: { level = log4cxx::Level::getWarn(); break; } case StringTable::LEVEL_ERROR: { level = log4cxx::Level::getError(); break; } case StringTable::LEVEL_FATAL: { level = log4cxx::Level::getFatal(); break; } default: BOOST_ASSERT(false && "undefined log type"); break; } LOG4CXX_LOG(CompilerLogger, level, file << ":" << line << ": " << message); }