Severson-Group / AMDC-Firmware

Embedded system code (C and Verilog) which runs the AMDC Hardware
http://docs.amdc.dev/firmware
BSD 3-Clause "New" or "Revised" License
30 stars 5 forks source link

Add run-time logging enabled check for Python #303

Open npetersen2 opened 1 year ago

npetersen2 commented 1 year ago

Many users have run into issues when they did not enable logging in the C code (via the usr/user_config.h) file, but then try to use the Python logger class. Since the log command is not "installed", the Python code fails with no helpful error message.

TODO

Fix this by adding a helpful error message to the Python code.

For example, this pseudo-code could run at the beginning of each AMDC_Logger class public method to ensure embedded support:

if !logging_support_enabled:
  resp = amdc.cmd("log")
  if resp[2] == "UNKNOWN_CMD":
    raise Exception("Logging capabilities are not enabled in the AMDC C code user config file")
  else:
    logging_support_enabled = True

and the logging_support_enabled would be a class property of the AMDC_Logger that starts as False