in source/config/Config.cpp [434:535]
bool PlainConfig::LogConfig::LoadFromJson(const Crt::JsonView &json)
{
const char *jsonKey = JSON_KEY_LOG_LEVEL;
if (json.ValueExists(jsonKey))
{
if (!json.GetString(jsonKey).empty())
{
try
{
deviceClientlogLevel = ParseDeviceClientLogLevel(json.GetString(jsonKey).c_str());
}
catch (const std::invalid_argument &e)
{
LOGM_ERROR(Config::TAG, "Unable to parse incoming log level value passed via JSON: %s", e.what());
return false;
}
}
else
{
LOGM_WARN(Config::TAG, "Key {%s} was provided in the JSON configuration file with an empty value", jsonKey);
}
}
jsonKey = JSON_KEY_LOG_TYPE;
if (json.ValueExists(jsonKey))
{
if (!json.GetString(jsonKey).empty())
{
try
{
deviceClientLogtype = ParseDeviceClientLogType(json.GetString(jsonKey).c_str());
}
catch (const std::invalid_argument &e)
{
LOGM_ERROR(Config::TAG, "Unable to parse incoming log type value passed via JSON: %s", e.what());
return false;
}
}
else
{
LOGM_WARN(Config::TAG, "Key {%s} was provided in the JSON configuration file with an empty value", jsonKey);
}
}
jsonKey = JSON_KEY_LOG_FILE;
if (json.ValueExists(jsonKey))
{
if (!json.GetString(jsonKey).empty())
{
deviceClientLogFile = FileUtils::ExtractExpandedPath(json.GetString(jsonKey).c_str());
}
else
{
LOGM_WARN(Config::TAG, "Key {%s} was provided in the JSON configuration file with an empty value", jsonKey);
}
}
jsonKey = JSON_KEY_ENABLE_SDK_LOGGING;
if (json.ValueExists(jsonKey) && json.GetBool(jsonKey))
{
if (json.GetBool(jsonKey))
{
sdkLoggingEnabled = true;
}
}
jsonKey = JSON_KEY_SDK_LOG_LEVEL;
if (json.ValueExists(jsonKey))
{
if (!json.GetString(jsonKey).empty())
{
try
{
sdkLogLevel = ParseSDKLogLevel(json.GetString(jsonKey).c_str());
}
catch (const std::invalid_argument &e)
{
LOGM_ERROR(Config::TAG, "Unable to parse incoming SDK log type value passed via JSON: %s", e.what());
return false;
}
}
else
{
LOGM_WARN(Config::TAG, "Key {%s} was provided in the JSON configuration file with an empty value", jsonKey);
}
}
jsonKey = JSON_KEY_SDK_LOG_FILE;
if (json.ValueExists(jsonKey))
{
if (!json.GetString(jsonKey).empty())
{
sdkLogFile = FileUtils::ExtractExpandedPath(json.GetString(jsonKey).c_str());
}
else
{
LOGM_WARN(Config::TAG, "Key {%s} was provided in the JSON configuration file with an empty value", jsonKey);
}
}
return true;
}