| 1224 | } |
| 1225 | |
| 1226 | bool LogerManager::configFromStringImpl(std::string content, bool isUpdate) |
| 1227 | { |
| 1228 | unsigned int sum = 0; |
| 1229 | for (std::string::iterator iter = content.begin(); iter != content.end(); ++iter) |
| 1230 | { |
| 1231 | sum += (unsigned char)*iter; |
| 1232 | } |
| 1233 | if (sum == _checksum) |
| 1234 | { |
| 1235 | return true; |
| 1236 | } |
| 1237 | _checksum = sum; |
| 1238 | |
| 1239 | |
| 1240 | std::map<std::string, LoggerInfo> loggerMap; |
| 1241 | if (!parseConfigFromString(content, loggerMap)) |
| 1242 | { |
| 1243 | std::cout << " !!! !!! !!! !!!" << std::endl; |
| 1244 | std::cout << " !!! !!! log4z load config file error" << std::endl; |
| 1245 | std::cout << " !!! !!! !!! !!!" << std::endl; |
| 1246 | return false; |
| 1247 | } |
| 1248 | for (std::map<std::string, LoggerInfo>::iterator iter = loggerMap.begin(); iter != loggerMap.end(); ++iter) |
| 1249 | { |
| 1250 | LoggerId id = LOG4Z_INVALID_LOGGER_ID; |
| 1251 | id = findLogger(iter->second._key.c_str()); |
| 1252 | if (id == LOG4Z_INVALID_LOGGER_ID) |
| 1253 | { |
| 1254 | if (isUpdate) |
| 1255 | { |
| 1256 | continue; |
| 1257 | } |
| 1258 | else |
| 1259 | { |
| 1260 | id = createLogger(iter->second._key.c_str()); |
| 1261 | if (id == LOG4Z_INVALID_LOGGER_ID) |
| 1262 | { |
| 1263 | continue; |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | enableLogger(id, iter->second._enable); |
| 1268 | setLoggerName(id, iter->second._name.c_str()); |
| 1269 | setLoggerPath(id, iter->second._path.c_str()); |
| 1270 | setLoggerLevel(id, iter->second._level); |
| 1271 | setLoggerFileLine(id, iter->second._fileLine); |
| 1272 | setLoggerDisplay(id, iter->second._display); |
| 1273 | setLoggerOutFile(id, iter->second._outfile); |
| 1274 | setLoggerLimitsize(id, iter->second._limitsize); |
| 1275 | } |
| 1276 | return true; |
| 1277 | } |
| 1278 | |
| 1279 | //! read configure and create with overwriting |
| 1280 | bool LogerManager::config(const char* configPath) |
nothing calls this directly
no test coverage detected