From c82a9f189a7b0121ec97b2fb76d7e8a5a99907e4 Mon Sep 17 00:00:00 2001 From: tzzed Date: Tue, 15 Aug 2023 21:17:15 +0400 Subject: [PATCH 1/4] refacto: set attribute name in error log --- src/lib/mongoBackend/MongoCommonUpdate.cpp | 4 ++-- src/lib/ngsi/ContextAttributeVector.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/mongoBackend/MongoCommonUpdate.cpp b/src/lib/mongoBackend/MongoCommonUpdate.cpp index e0b3f2f1d4..e00218931b 100644 --- a/src/lib/mongoBackend/MongoCommonUpdate.cpp +++ b/src/lib/mongoBackend/MongoCommonUpdate.cpp @@ -316,7 +316,7 @@ static bool attrValueChanges(const orion::BSONObj& attr, ContextAttribute* caP, return caP->valueType != orion::ValueTypeNull; default: - LM_E(("Runtime Error (unknown attribute value type in DB: %d)", getFieldF(attr, ENT_ATTRS_VALUE).type())); + LM_E(("Runtime Error (unknown attribute value type in DB: %d on attribute %s)", getFieldF(attr, ENT_ATTRS_VALUE).type(), caP->name.c_str())); return false; } } @@ -442,7 +442,7 @@ static ChangeType mergeAttrInfo break; default: - LM_E(("Runtime Error (unknown attribute value type in DB: %d)", getFieldF(attr, ENT_ATTRS_VALUE).type())); + LM_E(("Runtime Error (unknown attribute value type in DB: %d on attribute %s)", getFieldF(attr, ENT_ATTRS_VALUE).type(), caP->name.c_str())); } } diff --git a/src/lib/ngsi/ContextAttributeVector.cpp b/src/lib/ngsi/ContextAttributeVector.cpp index 234df01262..d0581a3ba6 100644 --- a/src/lib/ngsi/ContextAttributeVector.cpp +++ b/src/lib/ngsi/ContextAttributeVector.cpp @@ -389,7 +389,7 @@ void ContextAttributeVector::fill break; default: - LM_E(("Runtime Error (unknown attribute value type in DB: %d)", getFieldF(attr, ENT_ATTRS_VALUE).type())); + LM_E(("Runtime Error (unknown attribute value type in DB: %d on attribute %s)", getFieldF(attr, ENT_ATTRS_VALUE).type(), ca.name.c_str())); } } From de76dddb4f95d1e7d912873b9532a128943bf5b0 Mon Sep 17 00:00:00 2001 From: tzzed Date: Tue, 15 Aug 2023 21:35:27 +0400 Subject: [PATCH 2/4] refacto: harmonized logs --- src/lib/ngsi/ContextAttribute.cpp | 8 ++++---- src/lib/ngsi/ContextAttributeVector.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/ngsi/ContextAttribute.cpp b/src/lib/ngsi/ContextAttribute.cpp index 9a8f939c90..0f0e3520f4 100644 --- a/src/lib/ngsi/ContextAttribute.cpp +++ b/src/lib/ngsi/ContextAttribute.cpp @@ -133,7 +133,7 @@ void ContextAttribute::bsonAppendAttrValue break; default: - LM_E(("Runtime Error (unknown attribute type: %d)", valueType)); + LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", valueType, name.c_str())); } } @@ -217,7 +217,7 @@ bool ContextAttribute::calculateOperator return false; default: - LM_E(("Runtime Error (unknown attribute type: %d)", valueType)); + LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", valueType, name.c_str())); return false; } @@ -247,7 +247,7 @@ bool ContextAttribute::calculateOperator return false; default: - LM_E(("Runtime Error (unknown attribute type: %d)", valueType)); + LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", valueType, name.c_str())); return false; } } @@ -258,7 +258,7 @@ bool ContextAttribute::calculateOperator } else { - LM_E(("Runtime Error (uknown operator: %s)", op.c_str())); + LM_E(("Runtime Error (unknown operator: %s)", op.c_str())); return false; } diff --git a/src/lib/ngsi/ContextAttributeVector.cpp b/src/lib/ngsi/ContextAttributeVector.cpp index d0581a3ba6..3d3c70ce05 100644 --- a/src/lib/ngsi/ContextAttributeVector.cpp +++ b/src/lib/ngsi/ContextAttributeVector.cpp @@ -669,7 +669,7 @@ void ContextAttributeVector::applyUpdateOperators(void) break; default: - LM_E(("Runtime Error (unknown attribute type: %d)", upOp->valueType)); + LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", upOp->valueType, vec[ix]->name.c_str())); } // Replace old compound value (with $push) with the new one ([]) @@ -705,7 +705,7 @@ void ContextAttributeVector::applyUpdateOperators(void) break; default: - LM_E(("Runtime Error (unknown attribute type: %d)", upOp->valueType)); + LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", upOp->valueType, vec[ix]->name.c_str())); } // Replace old compound value (with $push) with the new one ([]) @@ -726,7 +726,7 @@ void ContextAttributeVector::applyUpdateOperators(void) } else { - LM_E(("Runtime Error (uknown operator: %s", op.c_str())); + LM_E(("Runtime Error (unknown operator: %s", op.c_str())); } } } From b0b45b37b1ebd080b056fba9d1bb5ed57f1605e7 Mon Sep 17 00:00:00 2001 From: tzzed Date: Tue, 22 Aug 2023 14:34:49 +0400 Subject: [PATCH 3/4] apply review suggestion --- CHANGES_NEXT_RELEASE | 1 + src/lib/ngsi/ContextAttribute.cpp | 6 +++--- src/lib/ngsi/ContextAttributeVector.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 528af55d4c..6387d816b3 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ - Fix: logDeprecate not working correctly (`geo:json` wrongly considered as deprecated) +- Fix improve error traces (#4387) diff --git a/src/lib/ngsi/ContextAttribute.cpp b/src/lib/ngsi/ContextAttribute.cpp index 0f0e3520f4..f2aade9e7b 100644 --- a/src/lib/ngsi/ContextAttribute.cpp +++ b/src/lib/ngsi/ContextAttribute.cpp @@ -133,7 +133,7 @@ void ContextAttribute::bsonAppendAttrValue break; default: - LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", valueType, name.c_str())); + LM_E(("Runtime Error (unknown attribute value type: %d on attribute %s)", valueType, name.c_str())); } } @@ -217,7 +217,7 @@ bool ContextAttribute::calculateOperator return false; default: - LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", valueType, name.c_str())); + LM_E(("Runtime Error (unknown attribute value type: %d on attribute %s)", valueType, name.c_str())); return false; } @@ -247,7 +247,7 @@ bool ContextAttribute::calculateOperator return false; default: - LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", valueType, name.c_str())); + LM_E(("Runtime Error (unknown attribute value type: %d on attribute %s)", valueType, name.c_str())); return false; } } diff --git a/src/lib/ngsi/ContextAttributeVector.cpp b/src/lib/ngsi/ContextAttributeVector.cpp index 3d3c70ce05..812f8c9af8 100644 --- a/src/lib/ngsi/ContextAttributeVector.cpp +++ b/src/lib/ngsi/ContextAttributeVector.cpp @@ -669,7 +669,7 @@ void ContextAttributeVector::applyUpdateOperators(void) break; default: - LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", upOp->valueType, vec[ix]->name.c_str())); + LM_E(("Runtime Error (unknown attribute value type: %d on attribute %s)", upOp->valueType, vec[ix]->name.c_str())); } // Replace old compound value (with $push) with the new one ([]) @@ -705,7 +705,7 @@ void ContextAttributeVector::applyUpdateOperators(void) break; default: - LM_E(("Runtime Error (unknown attribute type: %d on attribute %s)", upOp->valueType, vec[ix]->name.c_str())); + LM_E(("Runtime Error (unknown attribute value type: %d on attribute %s)", upOp->valueType, vec[ix]->name.c_str())); } // Replace old compound value (with $push) with the new one ([]) From ea3e728589d614494bcc3c8cb01cb7b23fa1a60e Mon Sep 17 00:00:00 2001 From: Tzzed Date: Tue, 22 Aug 2023 17:21:43 +0400 Subject: [PATCH 4/4] Update CHANGES_NEXT_RELEASE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 6387d816b3..8b17f72e51 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,2 +1,2 @@ - Fix: logDeprecate not working correctly (`geo:json` wrongly considered as deprecated) -- Fix improve error traces (#4387) +- Fix: improve error traces (#4387)