Example #1
0
bool LogerManager::configFromStringImpl(std::string content, bool isUpdate)
{
    unsigned int sum = 0;
    for (std::string::iterator iter = content.begin(); iter != content.end(); ++iter)
    {
        sum += (unsigned char)*iter;
    }
    if (sum == _checksum)
    {
        return true;
    }
    _checksum = sum;
    

    std::map<std::string, LoggerInfo> loggerMap;
    if (!parseConfigFromString(content, loggerMap))
    {
        printf(" !!! !!! !!! !!!\r\n");
		printf(" !!! !!! log4z load config file error \r\n");
		printf(" !!! !!! !!! !!!\r\n");
        return false;
    }
    for (std::map<std::string, LoggerInfo>::iterator iter = loggerMap.begin(); iter != loggerMap.end(); ++iter)
    {
        LoggerId id = LOG4Z_INVALID_LOGGER_ID;
        id = findLogger(iter->second._key.c_str());
        if (id == LOG4Z_INVALID_LOGGER_ID)
        {
            if (isUpdate)
            {
                continue;
            }
            else
            {
                id = createLogger(iter->second._key.c_str());
                if (id == LOG4Z_INVALID_LOGGER_ID)
                {
                    continue;
                }
            }
        }
        enableLogger(id, iter->second._enable);
        setLoggerName(id, iter->second._name.c_str());
        setLoggerPath(id, iter->second._path.c_str());
        setLoggerLevel(id, iter->second._level);
        setLoggerFileLine(id, iter->second._fileLine);
        setLoggerDisplay(id, iter->second._display);
        setLoggerOutFile(id, iter->second._outfile);
        setLoggerLimitsize(id, iter->second._limitsize);
        setLoggerMonthdir(id, iter->second._monthdir);
    }
    return true;
}
Example #2
0
bool LogerManager::configFromStringImpl(std::string content, bool isUpdate)
{
	std::map<std::string, LoggerInfo> loggerMap;
	if (!parseConfigFromString(content, loggerMap))
	{
		std::cout << " !!! !!! !!! !!!" << std::endl;
		std::cout << " !!! !!! log4z load config file error" << std::endl;
		std::cout << " !!! !!! !!! !!!" << std::endl;
		return false;
	}
	for (std::map<std::string, LoggerInfo>::iterator iter = loggerMap.begin(); iter != loggerMap.end(); ++iter)
	{
		LoggerId id = LOG4Z_INVALID_LOGGER_ID;
		id = findLogger(iter->second._key.c_str());
		if (id == LOG4Z_INVALID_LOGGER_ID)
		{
			if (isUpdate)
			{
				continue;
			}
			else
			{
				id = createLogger(iter->second._key.c_str());
				if (id == LOG4Z_INVALID_LOGGER_ID)
				{
					continue;
				}
			}
		}
		enableLogger(id, iter->second._enable);
		setLoggerName(id, iter->second._name.c_str());
		setLoggerPath(id, iter->second._path.c_str());
		setLoggerLevel(id, iter->second._level);
		setLoggerFileLine(id, iter->second._fileLine);
		setLoggerDisplay(id, iter->second._display);
		setLoggerOutFile(id, iter->second._outfile);
		setLoggerLimitsize(id, iter->second._limitsize);
		setLoggerMonthdir(id, iter->second._monthdir);
	}
	return true;
}