Skip to content

Commit 2bad98f

Browse files
committed
keep the logs consistent with concore.py
1 parent f534d71 commit 2bad98f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

concoredocker.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def read(port_identifier, name, initstr_val):
231231
ins = str(initstr_val)
232232
s += ins
233233
except Exception as e:
234-
logging.error(f"Error reading {file_path}: {e}")
234+
logging.error(f"Error reading {file_path}: {e}. Using default value.")
235235
return default_return_val
236236

237237
attempts = 0
@@ -262,7 +262,7 @@ def read(port_identifier, name, initstr_val):
262262
logging.warning(f"Warning: Unexpected data format in {file_path}: {ins}. Returning raw content or default.")
263263
return inval
264264
except Exception as e:
265-
logging.error(f"Error parsing {ins}: {e}")
265+
logging.error(f"Error parsing content from {file_path} ('{ins}'): {e}. Returning default.")
266266
return default_return_val
267267

268268
def write(port_identifier, name, val, delta=0):
@@ -287,14 +287,15 @@ def write(port_identifier, name, val, delta=0):
287287
if isinstance(val, str):
288288
time.sleep(2 * delay)
289289
elif not isinstance(val, list):
290-
logging.error("write must have list or str")
290+
logging.error(f"File write to {file_path} must have list or str value, got {type(val)}")
291291
return
292292

293293
try:
294294
with open(file_path, "w") as outfile:
295295
if isinstance(val, list):
296296
val_converted = convert_numpy_to_python(val)
297-
outfile.write(str([simtime + delta] + val_converted))
297+
data_to_write = [simtime + delta] + val_converted
298+
outfile.write(str(data_to_write))
298299
simtime += delta
299300
else:
300301
outfile.write(val)
@@ -311,12 +312,12 @@ def initval(simtime_val):
311312
simtime = first_element
312313
return val[1:]
313314
else:
314-
logging.error(f"Error: First element in initval string '{simtime_val}' is not a number.")
315+
logging.error(f"Error: First element in initval string '{simtime_val}' is not a number. Using data part as is or empty.")
315316
return val[1:] if len(val) > 1 else []
316317
else:
317-
logging.error(f"Error: initval string '{simtime_val}' is not a list or is empty.")
318+
logging.error(f"Error: initval string '{simtime_val}' is not a list or is empty. Returning empty list.")
318319
return []
319320
except Exception as e:
320-
logging.error(f"Error parsing simtime_val: {e}")
321+
logging.error(f"Error parsing simtime_val_str '{simtime_val}': {e}. Returning empty list.")
321322
return []
322323

0 commit comments

Comments
 (0)