void Logger::logDebug( const char *s , LogOutputMode mode ) { if( settings == NULL ) attachRoot(); if( settings -> logDisabled( Logger::LogLevelDebug ) ) return; log( s , mode , Logger::LogLevelDebug ); }
void Logger::log( const char *s , LogOutputMode mode , Logger::LogLevel p_logLevel ) { // check needs to be excluded if( settings == NULL ) attachRoot(); if( settings -> isExcluded( s ) ) return; AIEngine& engine = AIEngine::getInstance(); EngineThreadHelper *logTail = EngineThreadHelper::getThreadObject(); LogManager *logManager = engine.getLogManager(); if( logTail == NULL ) { logManager -> add( &s , 1 , p_logLevel , getPostfix() ); return; } // release old String& w = logTail -> lastMsg; if( logTail -> remains ) if( mode == Logger::LogStart || mode == Logger::LogDefault ) { const char *p = w; logManager -> add( &p , 1 , p_logLevel , getPostfix() ); logTail -> remains = false; w.clear(); } w += s; if( mode == Logger::LogLine || mode == Logger::LogStart ) w += "\n"; if( mode == Logger::LogStop || mode == Logger::LogDefault ) { const char *p = w; logManager -> add( &p , 1 , p_logLevel , getPostfix() ); logTail -> remains = false; w.clear(); } else logTail -> remains = true; }
void Logger::logObject( const char *prompt , Object *obj , Logger::LogLevel p_logLevel ) { if( settings == NULL ) attachRoot(); if( settings -> logDisabled( p_logLevel ) ) return; const char *lines[2]; String p = "%s: "; p += prompt; lines[ 0 ] = p; SerializeObject *so = obj -> getSerializeObject(); Object::serialize( obj , *so ); String data = so -> getDataStringNameToValue(); lines[ 1 ] = data; LogManager *logManager = AIEngine::getInstance().getLogManager(); logManager -> add( lines , 2 , p_logLevel , getPostfix() ); }
std::unique_ptr<Element> Frame::replaceRoot(std::unique_ptr<Element> upElement) { auto upOldRoot = std::move(mupRoot); attachRoot(std::move(upElement)); return std::move(upOldRoot); }
Xml Logger::getLogSettings() { if( settings == NULL ) attachRoot(); return( settings -> getXml() ); }
bool Logger::isLogAll() { if( settings == NULL ) attachRoot(); return( settings -> getLevel() == LogLevelDebug ); }