当前位置: 首页>>代码示例>>C++>>正文


C++ ErrorLogger类代码示例

本文整理汇总了C++中ErrorLogger的典型用法代码示例。如果您正苦于以下问题:C++ ErrorLogger类的具体用法?C++ ErrorLogger怎么用?C++ ErrorLogger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ErrorLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: refresh

void Dying::refresh()
{
    ErrorLogger* logger = ErrorLogger::Instance();
    int ret = executable->getBroker()->running();
    if(ret == 0)
        Dying::moduleFailed();
    else if(ret == -1)
        logger->addError(executable->getBroker()->error());

}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:10,代码来源:execstate.cpp

示例2: init

bool XmlModLoader::init()
{
    module.clear();
    fileNames.clear();
    ErrorLogger* logger  = ErrorLogger::Instance();

    /**
     * loading single module indicated by its xml file name
     */
    if(!strFileName.empty())
    {
        fileNames.push_back(strFileName);
        return true;
    }

    if(strPath.empty())
    {
        logger->addError("No module path is introduced.");
        return false;
    }

    DIR *dir;
    struct dirent *entry;
    if ((dir = opendir(strPath.c_str())) == nullptr)
    {
        OSTRINGSTREAM err;
        err<<"Cannot access "<<strPath;
        logger->addError(err);
        return false;
    }

    /* we need to load all xml modules */
    while((entry = readdir(dir)))
    {
        string name = entry->d_name;
        if(name.size() > 3)
        {
            string ext = name.substr(name.size()-3,3);
            if(compareString(ext.c_str(), "xml"))
                fileNames.push_back(strPath+name);
        }
    }
    closedir(dir);

    /*
    if(fileNames.empty())
    {
        OSTRINGSTREAM err;
        err<<"No xml module file found in "<<strPath;
        logger->addWarning(err);
        //return true;
    }
    */
    return true;
}
开发者ID:robotology,项目名称:yarp,代码行数:55,代码来源:xmlmodloader.cpp

示例3: refresh

// refresh() from Suspended can be used for recovering from 
// unexptected termination of manager. 
void Suspended::refresh(void)
{
    ErrorLogger* logger = ErrorLogger::Instance();
    int ret = executable->getBroker()->running();
    if(ret == 1)
    {
        executable->getEvent()->onExecutableStart(executable);
        castEvent(EventFactory::recoverEvent);
    }
    else if(ret == -1)
        logger->addError(executable->getBroker()->error());
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:14,代码来源:execstate.cpp

示例4: __CHECK_NULLPTR

bool Arbitrator::trainWeights(const char* opnd)
{
    __CHECK_NULLPTR(opnd);

    ErrorLogger* logger  = ErrorLogger::Instance();

    string rule = getRule(opnd);
    if(!rule.length())
    {
        std::map<std::string, double> w;
        alphas[opnd] = w;
        biases[opnd] = 1.0;
        return true; 
    }

    BinaryExpParser parser;
    std::map<string, string>::iterator itr;
    for(itr=rules.begin(); itr!=rules.end(); itr++)
        parser.addRestrictedOperand((itr->first).c_str());         

    // parsing the compact logic
    rule = string(opnd) + " : " + rule;
    if(!parser.parse(rule.c_str()))
        return false;

    // trining the weights
    LinkTrainer trainer; 
    if(trainer.train(parser.getTruthTable()))
    {
        biases[opnd] = trainer.getBias();

        std::vector<double> alf = trainer.getAlphas();
        std::map<std::string, double> w;

        std::map<std::string, bool>::iterator itr;
        std::map<std::string, bool> operands = parser.getOperands();
        int i=0;
        for(itr=operands.begin(); itr!=operands.end(); itr++)
        {
            w[itr->first] = alf[i];
            i++;
        }            
        alphas[opnd] = w;
    }
    else
    {
        logger->addError("Maximum number of iterations is reached without finding any solution. Check for the correctness of the expression logic.");
        return false;
    }        

    return true;
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:52,代码来源:arbitrator.cpp

示例5: reportErrors

void YConsoleManager::reportErrors(void)
{
    ErrorLogger* logger  = ErrorLogger::Instance();
    if(logger->errorCount() || logger->warningCount())
    {
        const char* msg;
        while((msg=logger->getLastError()))
            cout<<FAIL<<"ERROR:   "<<INFO<<msg<<ENDC<<endl;

        while((msg=logger->getLastWarning()))
            cout<<WARNING<<"WARNING: "<<INFO<<msg<<ENDC<<endl;
    }
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:13,代码来源:ymanager.cpp

示例6: init

bool SingleAppLoader::init(void)
{
    ErrorLogger* logger  = ErrorLogger::Instance();
    app.clear();
    if(strModule.empty())
    {
        logger->addError("Empty module name.");
        return false;
    }

    app.setName(strModule.c_str());
    ModuleInterface module(strModule.c_str());
    module.setHost(strHost.c_str());
    app.addImodule(module);
    return true;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:16,代码来源:singleapploader.cpp

示例7: killModule

void Dying::killModule(void)
{   
    ErrorLogger* logger = ErrorLogger::Instance();
    if(!executable->getBroker()->kill())
    {
        OSTRINGSTREAM msg;
        msg<<"cannot kill "<<executable->getCommand()<<" on "<<executable->getHost();
        if(executable->getBroker()->error())
            msg<<" : "<<executable->getBroker()->error();
        logger->addError(msg);
        executable->getEvent()->onError(executable);
        castEvent(EventFactory::killModuleEventFailed);
    }
    else
    {
        castEvent(EventFactory::killModuleEventOk);
        executable->getEvent()->onExecutableDied(executable);
    }
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:19,代码来源:execstate.cpp

示例8: disconnectAllPorts

void Dying::disconnectAllPorts(void)
{
    ErrorLogger* logger = ErrorLogger::Instance();
    if(executable->autoConnect())
    {
        CnnIterator itr;
        for(itr=executable->getConnections().begin();
            itr!=executable->getConnections().end(); itr++)
        {
            if( !executable->getBroker()->disconnect((*itr).from(), (*itr).to()) )
            {
                OSTRINGSTREAM msg;
                msg<<"cannot disconnect "<<(*itr).from() <<" to "<<(*itr).to();
                if(executable->getBroker()->error())
                    msg<<" : "<<executable->getBroker()->error();
                logger->addError(msg);          
            }
            else
                executable->getEvent()->onCnnReleased(&(*itr));
        }
    }
    // We do not need to handle event disconnectAllPortsEventOk 
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:23,代码来源:execstate.cpp

示例9: WAIT_SEMAPHOR

void SafeManager::onExecutableFailed(void* which)
{
    WAIT_SEMAPHOR();
    ErrorLogger* logger  = ErrorLogger::Instance();
    Executable* exe = static_cast<Executable*>(which);
    if(exe)
    {
        if(m_pConfig->find("module_failure").asString() == "prompt")
        {
            OSTRINGSTREAM err;
            err<<exe->getCommand()<<" from "<<exe->getHost()<<" is failed! [id:"<<exe->getID()<<"]";
            logger->addError(err);
            if(eventReceiver && exe)
                eventReceiver->onModStop(exe->getID());
        }

        if(m_pConfig->find("module_failure").asString() == "recover")
        {
            OSTRINGSTREAM err;
            err<<exe->getCommand()<<" from "<<exe->getHost()<<" is failed! [id:"<<exe->getID()<<"] (restarting...)";
            logger->addError(err);
            exe->start();
         }

        if(m_pConfig->find("module_failure").asString() == "terminate")
        {
            OSTRINGSTREAM err;
            err<<exe->getCommand()<<" from "<<exe->getHost()<<" is failed! [id:"<<exe->getID()<<"] (terminating...)";
            logger->addError(err);
            Manager::stop();
        }
    }

    if(eventReceiver)
            eventReceiver->onError();
    POST_SEMAPHOR();
}
开发者ID:jgvictores,项目名称:yarp,代码行数:37,代码来源:safe_manager.cpp

示例10: stopModule

void Dying::stopModule()
{
    ErrorLogger* logger = ErrorLogger::Instance();
    if (executable->getPostStopWait() > 0)
    {
        yarp::os::SystemClock::delaySystem(executable->getPostStopWait());
    }
    executable->restoreOriginalPostStopWait();
    if(!executable->getBroker()->stop())
    {
        OSTRINGSTREAM msg;
        msg<<"cannot stop "<<executable->getCommand()<<" on "<<executable->getHost();
        if(executable->getBroker()->error())
            msg<<" : "<<executable->getBroker()->error();
        logger->addError(msg);
        executable->getEvent()->onError(executable);
        castEvent(EventFactory::stopModuleEventFailed);
    }
    else
    {
        castEvent(EventFactory::stopModuleEventOk);
        executable->getEvent()->onExecutableStop(executable);
    }
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:24,代码来源:execstate.cpp

示例11: errmsg

bool CheckNullPointer::analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger)
{
    if (!ctu)
        return false;
    bool foundErrors = false;
    (void)settings; // This argument is unused

    const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> callsMap = ctu->getCallsMap();

    for (Check::FileInfo *fi1 : fileInfo) {
        const MyFileInfo *fi = dynamic_cast<MyFileInfo*>(fi1);
        if (!fi)
            continue;
        for (const CTU::FileInfo::UnsafeUsage &unsafeUsage : fi->unsafeUsage) {
            for (int warning = 0; warning <= 1; warning++) {
                if (warning == 1 && !settings.isEnabled(Settings::WARNING))
                    break;

                const std::list<ErrorLogger::ErrorMessage::FileLocation> &locationList =
                    ctu->getErrorPath(CTU::FileInfo::InvalidValueType::null,
                                      unsafeUsage,
                                      callsMap,
                                      "Dereferencing argument ARG that is null",
                                      nullptr,
                                      warning);
                if (locationList.empty())
                    continue;

                const ErrorLogger::ErrorMessage errmsg(locationList,
                                                       emptyString,
                                                       warning ? Severity::warning : Severity::error,
                                                       "Null pointer dereference: " + unsafeUsage.myArgumentName,
                                                       "ctunullpointer",
                                                       CWE476, false);
                errorLogger.reportErr(errmsg);

                foundErrors = true;
                break;
            }
        }
    }

    return foundErrors;
}
开发者ID:matthiaskrgr,项目名称:cppcheck,代码行数:44,代码来源:checknullpointer.cpp

示例12: parsXml

Module* XmlModLoader::parsXml(const char* szFile)
{
    module.clear();
    ErrorLogger* logger  = ErrorLogger::Instance();

    TiXmlDocument doc(szFile);
    if(!doc.LoadFile())
    {
        OSTRINGSTREAM err;
        err<<"Syntax error while loading "<<szFile<<" at line "\
           <<doc.ErrorRow()<<": ";
        err<<doc.ErrorDesc();
        logger->addError(err);
        return nullptr;
    }

    /* retrieving root module */
    TiXmlElement *root = doc.RootElement();
    if(!root)
    {
        OSTRINGSTREAM err;
        err<<"Syntax error while loading "<<szFile<<" . ";
        err<<"No root element.";
        logger->addError(err);
        return nullptr;
    }

    if(!compareString(root->Value(), "module"))
    {
        /*
        OSTRINGSTREAM msg;
        msg<<szFile<<" is not a module descriptor file.";
        logger->addWarning(msg);
        */
        return nullptr;
    }

    /* retrieving name */
    auto* name = (TiXmlElement*) root->FirstChild("name");
    if(!name || !name->GetText())
    {
        OSTRINGSTREAM err;
        err<<"Module from "<<szFile<<" has no name.";
        logger->addError(err);
        //return NULL;
    }

    for(TiXmlElement* var = root->FirstChildElement("var"); var; var = var->NextSiblingElement())
    {
        if(var->Attribute("name") && var->GetText())
        {
            parser->addVariable(var->Attribute("name"), var->GetText());
        }
    }

    module.setXmlFile(szFile);

    if(name)
        module.setName(parser->parseText(name->GetText()).c_str());

    /* retrieving description */
    TiXmlElement* desc;
    if((desc = (TiXmlElement*) root->FirstChild("description")))
        module.setDescription(parser->parseText(desc->GetText()).c_str());

    /* retrieving version */
    TiXmlElement* ver;
    if((ver = (TiXmlElement*) root->FirstChild("version")))
        module.setVersion(parser->parseText(ver->GetText()).c_str());


    /* retrieving parameter */
    TiXmlElement* arguments;
    if((arguments = (TiXmlElement*) root->FirstChild("arguments")))
        for(TiXmlElement* param = arguments->FirstChildElement(); param;
                param = param->NextSiblingElement())
        {
            if(compareString(param->Value(), "param"))
            {
                if(param->GetText())
                {
                    bool brequired = false;
                    if(compareString(param->Attribute("required"), "yes"))
                        brequired = true;
                    Argument arg(parser->parseText(param->GetText()).c_str(),
                                 brequired,
                                 param->Attribute("desc"));
                    arg.setDefault(param->Attribute("default"));
                    module.addArgument(arg);
                }
            }
            else
            if(compareString(param->Value(), "switch"))
            {
                if(param->GetText())
                {
                    bool brequired = false;
                    if(compareString(param->Attribute("required"), "yes"))
                        brequired = true;
                    Argument arg(parser->parseText(param->GetText()).c_str(),
//.........这里部分代码省略.........
开发者ID:robotology,项目名称:yarp,代码行数:101,代码来源:xmlmodloader.cpp

示例13: serialXml

bool XmlAppSaver::serialXml(Application* app, const char* szFile)
{

    // updating application xml file name
    app->setXmlFile(szFile);

    ErrorLogger* logger  = ErrorLogger::Instance();

    TiXmlDocument doc; //(szFile);
    TiXmlElement * root = new TiXmlElement("application");
    doc.LinkEndChild( root );
    TiXmlElement * appName = new TiXmlElement("name");  //are all these NEW ok?
    appName->LinkEndChild(new TiXmlText(app->getName()));
    root->LinkEndChild(appName);


    if (strcmp(app->getDescription(), ""))
    {
        TiXmlElement * desc= new TiXmlElement( "description");
        desc->LinkEndChild(new TiXmlText( app->getDescription()));
        root->LinkEndChild(desc);
    }

    if(strcmp (app->getVersion(), ""))
    {
        TiXmlElement * vers= new TiXmlElement( "version");
        vers->LinkEndChild(new TiXmlText( app->getVersion()));
        root->LinkEndChild(vers);

    }

    /*
     * TODO: setting prefix of the main application is inactivated.
     * Check this should be supported in future or not!
     */
    /*
    if(strcmp (app->getPrefix(), ""))
        {
        TiXmlElement * prefix= new TiXmlElement( "prefix");
        prefix->LinkEndChild(new TiXmlText( app->getPrefix()));
        root->LinkEndChild(prefix);

    }
    */

    if(app->authorCount()>0)
    {
        TiXmlElement *auths=new TiXmlElement("authors");
        for (int i=0; i<app->authorCount(); i++)
        {
            //app->getAuthorAt(i);
            TiXmlElement *auth=new TiXmlElement("author");
            auth->SetAttribute("email", app->getAuthorAt(i).getEmail());
            auth->LinkEndChild(new TiXmlText(app->getAuthorAt(i).getName()));
            auths->LinkEndChild(auth);
        }
        root->LinkEndChild(auths);
    }

    // iterate over modules
    {
        int nModules=app->imoduleCount();
        for (int modCt=0; modCt<nModules; ++modCt)
        {
            TiXmlElement * newMod = new TiXmlElement("module");
            root->LinkEndChild(newMod); //add module element
            ModuleInterface curMod=app->getImoduleAt(modCt);

            TiXmlElement *name = new TiXmlElement("name");
            name->LinkEndChild(new TiXmlText(curMod.getName()));
            newMod->LinkEndChild(name);

            TiXmlElement *parameters=new TiXmlElement("parameters");
            parameters->LinkEndChild(new TiXmlText(curMod.getParam()));
            newMod->LinkEndChild(parameters);

            TiXmlElement *node = new TiXmlElement("node");
            node->LinkEndChild(new TiXmlText(curMod.getHost())); //is host the same as node?
            newMod->LinkEndChild(node);

            TiXmlElement *prefix=new TiXmlElement("prefix");
            prefix->LinkEndChild(new TiXmlText(curMod.getPrefix()));
            newMod->LinkEndChild(prefix);

            if(strcmp(curMod.getStdio(), ""))
            {
                TiXmlElement *stdio=new TiXmlElement("stdio");
                stdio->LinkEndChild(new TiXmlText(curMod.getStdio()));
                newMod->LinkEndChild(stdio);
            }

            if(strcmp(curMod.getWorkDir(), ""))
            {
                TiXmlElement *workdir=new TiXmlElement("workdir");
                workdir->LinkEndChild(new TiXmlText(curMod.getWorkDir()));
                newMod->LinkEndChild(workdir);
            }

            if(strcmp(curMod.getBroker(), ""))
            {
//.........这里部分代码省略.........
开发者ID:jgvictores,项目名称:yarp,代码行数:101,代码来源:xmlappsaver.cpp

示例14: Manager


//.........这里部分代码省略.........

    if(!config.check("silent"))
    {
        cout<<endl<<OKGREEN<<LOGO_MESSAGE<<ENDC<<endl;
        cout<<endl<<WELCOME_MESSAGE<<endl<<endl;
    }

    if(config.check("modpath"))
    {
        string strPath;
        stringstream modPaths(config.find("modpath").asString().c_str());
        while (getline(modPaths, strPath, ';'))
        {
            trimString(strPath);
            if (!isAbsolute(strPath.c_str()))
                strPath=inipath+strPath;
            addModules(strPath.c_str());
        }
    }

    if(config.check("respath"))
    {
        string strPath;
        stringstream resPaths(config.find("respath").asString().c_str());
        while (getline(resPaths, strPath, ';'))
        {
            trimString(strPath);
            if (!isAbsolute(strPath.c_str()))
                strPath=inipath+strPath;
            addResources(strPath.c_str());
        }
    }

    ErrorLogger* logger  = ErrorLogger::Instance();
    if(config.check("apppath"))
    {
        string strPath;
        stringstream appPaths(config.find("apppath").asString().c_str());
        while (getline(appPaths, strPath, ';'))
        {
            trimString(strPath);
            if (!isAbsolute(strPath.c_str()))
                strPath=inipath+strPath;
            if(config.find("load_subfolders").asString() == "yes")
            {
                if(!loadRecursiveApplications(strPath.c_str()))
                    logger->addError("Cannot load the applications from  " + strPath);
            }
            else
                addApplications(strPath.c_str());
        }
    }

    reportErrors();

#ifdef WITH_READLINE
    updateAppNames(&appnames);
#endif


#if defined(WIN32)
    ACE_OS::signal(SIGINT, (ACE_SignalHandler) YConsoleManager::onSignal);
    ACE_OS::signal(SIGBREAK, (ACE_SignalHandler) YConsoleManager::onSignal);
    ACE_OS::signal(SIGTERM, (ACE_SignalHandler) YConsoleManager::onSignal);
#else
    struct sigaction new_action, old_action;
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:67,代码来源:ymanager.cpp

示例15: checkExpression

bool BinaryExpParser::checkExpression(std::string& strexp)
{
    ErrorLogger* logger = ErrorLogger::Instance();

    if(std::count(strexp.begin(), strexp.end(), '(') != 
        std::count(strexp.begin(), strexp.end(), ')'))
    {
        logger->addError("Incorrect expression format! (parentheses do not match)");
        return false;
    }
    if(std::count(strexp.begin(), strexp.end(), IMPLY) != 1 )
    {
        logger->addError("Incorrect expression format! (no implication ':' found)");
        return false;
    }

    // erassing all the sapces
    strexp.erase(std::remove_if(strexp.begin(), strexp.end(), ::isspace), strexp.end());
    if(!strexp.size())
    {
       logger->addError("Empty expression!");
       return false;
    }

    // making a copy of strexp and checking more
    string  dummy = strexp;
    // removing all pranteses 
    dummy.erase(std::remove_if(dummy.begin(), dummy.end(), isParentheses), dummy.end());
    leftOpr = dummy.substr(0, dummy.find(IMPLY)); 
    if(!leftOpr.size())
    {
        logger->addError("Missing operand before ':'");
        return false; 
    }
    if(dummy.find(IMPLY) == (dummy.size()-1))
    {
        logger->addError("Missing operands after ':'");
        return false; 
    }

    dummy.erase(0, dummy.find(IMPLY)+1);
    if(dummy.find(leftOpr) != string::npos)
    {
        std::string msg;
        msg = "recursive assignment of operand '" + leftOpr + "'";
        logger->addError(msg.c_str());
        return false;       
    }

    // checking '~'
    size_t n = dummy.find(EXPNOT);
    while(n != string::npos)
    { 
        OSTRINGSTREAM msg;        
        bool bError = ((n+1) == dummy.length()); // empty operand after ~
        if((n+1) < dummy.length())
        {
            bError |= (dummy[n+1] == EXPAND);        // operator & after ~
            bError |= (dummy[n+1] == EXPOR);         // operand | after ~
        }            
        if(n != 0)
            bError |= (dummy[n-1] != EXPAND) && (dummy[n-1] != EXPOR);  // an operand before ~
        if(bError)
        {
            msg<<"Incorrect expression format of '~' at "<<(int)n;
            logger->addError(msg.str().c_str());
            return false;
        }
        n = dummy.find(EXPNOT, n+1);
    }

    // checking '| &'
    n = dummy.find_first_of("&|");
    while(n != string::npos)
    {
        OSTRINGSTREAM msg;        
        bool bError = ((n+1) == dummy.length());    // empty operand after & or |
        if((n+1) < dummy.length())
        {
            bError |= (dummy[n+1] == EXPAND);        // operator & after & or |
            bError |= (dummy[n+1] == EXPOR);         // operand | after & or |
        }            
        bError |= (n == 0);                      // empty operand before & or |
        if(n != 0)
        {
            bError |= (dummy[n-1] == EXPAND);        // operator & before & or |
            bError |= (dummy[n-1] == EXPOR);         // operand | before & or |
            bError |= (dummy[n-1] == EXPOR);         // operand ~ before & or |
        } 
        if(bError)
        {
            msg<<"Incorrect expression format of '&' or '|' at "<<(int)n;
            logger->addError(msg.str().c_str());
            return false;
        }
        n = dummy.find_first_of("&|", n+1);
    }

    // at the end
    strexp.erase(0, strexp.find(IMPLY)+1);
//.........这里部分代码省略.........
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:101,代码来源:binexparser.cpp


注:本文中的ErrorLogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。