Do not log unknown operations as an error for backward/foward compatibility

This commit is contained in:
Uwe Seimet 2023-10-26 21:04:08 +02:00
parent 2be845e4aa
commit 12ea3b6721
4 changed files with 16 additions and 10 deletions

View File

@ -60,7 +60,13 @@ bool CommandContext::ReturnLocalizedError(LocalizationKey key, PbErrorCode error
const string& arg2, const string& arg3) const
{
// For the logfile always use English
spdlog::error(localizer.Localize(key, "en", arg1, arg2, arg3));
// Do not log unknown operations as an error for backward/foward compatibility with old/new clients
if (error_code == PbErrorCode::UNKNOWN_OPERATION) {
spdlog::trace(localizer.Localize(key, "en", arg1, arg2, arg3));
}
else {
spdlog::error(localizer.Localize(key, "en", arg1, arg2, arg3));
}
return ReturnStatus(false, localizer.Localize(key, locale, arg1, arg2, arg3), error_code, false);
}

View File

@ -22,12 +22,12 @@ Localizer::Localizer()
Add(LocalizationKey::ERROR_AUTHENTICATION, "es", "Fallo de autentificación");
Add(LocalizationKey::ERROR_AUTHENTICATION, "zh", "认证失败");
Add(LocalizationKey::ERROR_OPERATION, "en", "Unknown operation");
Add(LocalizationKey::ERROR_OPERATION, "de", "Unbekannte Operation");
Add(LocalizationKey::ERROR_OPERATION, "sv", "Okänd operation");
Add(LocalizationKey::ERROR_OPERATION, "fr", "Opération inconnue");
Add(LocalizationKey::ERROR_OPERATION, "es", "Operación desconocida");
Add(LocalizationKey::ERROR_OPERATION, "zh", "未知操作");
Add(LocalizationKey::ERROR_OPERATION, "en", "Unknown operation: %1");
Add(LocalizationKey::ERROR_OPERATION, "de", "Unbekannte Operation: %1");
Add(LocalizationKey::ERROR_OPERATION, "sv", "Okänd operation: %1");
Add(LocalizationKey::ERROR_OPERATION, "fr", "Opération inconnue: %1");
Add(LocalizationKey::ERROR_OPERATION, "es", "Operación desconocida: %1");
Add(LocalizationKey::ERROR_OPERATION, "zh", "未知操作: %1");
Add(LocalizationKey::ERROR_LOG_LEVEL, "en", "Invalid log level '%1'");
Add(LocalizationKey::ERROR_LOG_LEVEL, "de", "Ungültiger Log-Level '%1'");

View File

@ -323,9 +323,9 @@ bool Piscsi::ExecuteCommand(const CommandContext& context)
}
if (!PbOperation_IsValid(operation)) {
spdlog::error("Received unknown command with operation opcode " + to_string(operation));
spdlog::trace("Ignored unknown command with operation opcode " + to_string(operation));
return context.ReturnLocalizedError(LocalizationKey::ERROR_OPERATION, UNKNOWN_OPERATION);
return context.ReturnLocalizedError(LocalizationKey::ERROR_OPERATION, UNKNOWN_OPERATION, to_string(operation));
}
spdlog::trace("Received " + PbOperation_Name(operation) + " command");

View File

@ -79,7 +79,7 @@ bool PiscsiExecutor::ProcessDeviceCmd(const CommandContext& context, const PbDev
break;
default:
return context.ReturnLocalizedError(LocalizationKey::ERROR_OPERATION);
return context.ReturnLocalizedError(LocalizationKey::ERROR_OPERATION, to_string(operation));
}
return true;