SIENTIAPDE-1199

Refactor logging in OpcRepository to include full metadata in error and info messages

- Updated logging statements in the OpcRepository class to pass the complete metadata object instead of just the schedule name, enhancing the context available for debugging and monitoring.
This commit is contained in:
vitor-aignosi
2025-08-19 11:52:42 -03:00
parent 3a06f0ca39
commit 8012ff778c

View File

@@ -250,7 +250,7 @@ class OpcRepository():
data = data_type_map[data_type]['converter'](value) data = data_type_map[data_type]['converter'](value)
logger.custom_info( logger.custom_info(
f'Writing {data} - {type(data)} to {node}', metadata.get('schedule_name', 'N/A')) f'Writing {data} - {type(data)} to {node}', metadata)
now = datetime.now() now = datetime.now()
ua_data = DataValue( ua_data = DataValue(
Variant(data, data_type_map[data_type]['opc_type']), Variant(data, data_type_map[data_type]['opc_type']),
@@ -286,7 +286,7 @@ class OpcRepository():
except Exception as e: except Exception as e:
trace = traceback.format_exc() trace = traceback.format_exc()
logger.custom_error(trace, metadata.get('schedule_name', 'N/A')) logger.custom_error(trace, metadata)
self.error_count += 1 self.error_count += 1
return False, { return False, {
"notification_id": f"OPC_WRITE_DATA_ERROR_{self.id}", "notification_id": f"OPC_WRITE_DATA_ERROR_{self.id}",