Beispiel #1
0
void Hierarchy::updateParents(LoggerPtr logger)
{
        synchronized sync(mutex);
        const LogString name(logger->getName());
        int length = name.size();
        bool parentFound = false;


        // if name = "w.x.y.z", loop thourgh "w.x.y", "w.x" and "w", but not "w.x.y.z"
        for(size_t i = name.find_last_of(0x2E /* '.' */, length-1);
            i != LogString::npos;
            i = name.find_last_of(0x2E /* '.' */, i-1))
        {
                LogString substr = name.substr(0, i);

                LoggerMap::iterator it = loggers->find(substr);
                if(it != loggers->end())
                {
                        parentFound = true;
                        logger->parent = it->second;
                        break; // no need to update the ancestors of the closest ancestor
                }
                else
                {
                        ProvisionNodeMap::iterator it2 = provisionNodes->find(substr);
                        if (it2 != provisionNodes->end())
                        {
                                it2->second.push_back(logger);
                        }
                        else
                        {
                                ProvisionNode node(1, logger);
                                provisionNodes->insert(
                                        ProvisionNodeMap::value_type(substr, node));
                        }
                }
        }

        // If we could not find any existing parents, then link with root.
        if(!parentFound)
        {
                logger->parent = root;
        }
}
Beispiel #2
0
void LogManager::writeLog(LogString logString)
{
    ::write(stdout->_file, logString.c_str(), logString.size());
}