Skip to content

Commit

Permalink
Modify log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanielloNTIA committed Oct 25, 2023
1 parent 7790000 commit b33463a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scos_actions/actions/calibrate_y_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, parameters, sigan, gps=None):
try:
self.iir_apply = get_parameter(IIR_APPLY, parameters)
except ParameterException:
logger.info(
logger.debug(
"Config parameter 'iir_apply' not provided. "
+ "No IIR filtering will be used during calibration."
)
Expand Down
12 changes: 5 additions & 7 deletions scos_actions/calibration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ def get_sigan_calibration(sigan_cal_file: Path) -> Calibration:
"""
try:
sigan_cal = load_from_json(sigan_cal_file)
except Exception as err:
except Exception:
sigan_cal = None
logger.error("Unable to load sigan calibration data, reverting to none")
logger.exception(err)
logger.exception("Unable to load sigan calibration data, reverting to none")
return sigan_cal


Expand All @@ -34,10 +33,9 @@ def get_sensor_calibration(sensor_cal_file: Path) -> Calibration:
"""
try:
sensor_cal = load_from_json(sensor_cal_file)
except Exception as err:
except Exception:
sensor_cal = None
logger.error("Unable to load sensor calibration data, reverting to none")
logger.exception(err)
logger.exception("Unable to load sensor calibration data, reverting to none")
return sensor_cal


Expand All @@ -46,4 +44,4 @@ def get_sensor_calibration(sensor_cal_file: Path) -> Calibration:
logger.info(f"Loading sigan cal file: {SIGAN_CALIBRATION_FILE}")
sigan_calibration = get_sigan_calibration(SIGAN_CALIBRATION_FILE)
if sensor_calibration:
logger.info(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}")
logger.debug(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}")
7 changes: 3 additions & 4 deletions scos_actions/capabilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SENSOR_DEFINITION_HASH = None
SENSOR_LOCATION = None

logger.info(f"Loading {SENSOR_DEFINITION_FILE}")
logger.debug(f"Loading {SENSOR_DEFINITION_FILE}")
try:
capabilities["sensor"] = utils.load_from_json(SENSOR_DEFINITION_FILE)
except Exception as e:
Expand All @@ -32,7 +32,7 @@
sensor_loc["z"] if "z" in sensor_loc else None,
)
except:
logger.warning("Failed to get sensor location from sensor definition.")
logger.exception("Failed to get sensor location from sensor definition.")

# Generate sensor definition file hash (SHA 512)
try:
Expand All @@ -41,7 +41,6 @@
SENSOR_DEFINITION_HASH = hashlib.sha512(sensor_def.encode("UTF-8")).hexdigest()
capabilities["sensor"]["sensor_sha512"] = SENSOR_DEFINITION_HASH
except:
logger.error(f"Unable to generate sensor definition hash")
capabilities["sensor"]["sensor_sha512"] = "ERROR GENERATING HASH"
# SENSOR_DEFINITION_HASH is None, do not raise Exception
logger.debug(e)
logger.exception(f"Unable to generate sensor definition hash")
10 changes: 4 additions & 6 deletions scos_actions/discover/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ def load_from_yaml(action_classes, sigan, gps, yaml_dir: Path = ACTION_DEFINITIO
definition = yaml.load(yaml_file)
for class_name, parameters in definition.items():
try:
logger.debug("Attempting to configure: " + class_name)
logger.debug(f"Attempting to configure: {class_name}")
action = action_classes[class_name](
parameters=parameters, sigan=sigan, gps=gps
)
parsed_actions[action.name] = action
except KeyError as exc:
err = "Nonexistent action class name {!r} referenced in {!r}"
logger.error(err.format(class_name, yaml_file.name))
logger.exception(exc)
logger.exception(err.format(class_name, yaml_file.name))
raise exc
except TypeError as exc:
err = "Invalid parameter list {!r} referenced in {!r}"
logger.error(err.format(parameters, yaml_file.name))
logger.exception(exc)
logger.exception(err.format(parameters, yaml_file.name))
raise exc
except Exception as exc:
logger.error("Unable to load yaml:", exc, class_name, parameters)
logger.exception("Unable to load yaml:", class_name, parameters)
raise exc
return parsed_actions
8 changes: 4 additions & 4 deletions scos_actions/hardware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def load_switches(switch_dir: Path) -> dict:
if switch_dir is not None and switch_dir.is_dir():
for f in switch_dir.iterdir():
file_path = f.resolve()
logger.info(f"loading switch config {file_path}")
logger.debug(f"loading switch config {file_path}")
conf = utils.load_from_json(file_path)
try:
switch = ControlByWebWebRelay(conf)
logger.info(f"Adding {switch.id}")
logger.debug(f"Adding {switch.id}")

switch_dict[switch.id] = switch
logger.info(f"Registering switch status for {switch.name}")
logger.debug(f"Registering switch status for {switch.name}")
register_component_with_status.send(__name__, component=switch)
except ConfigurationException:
logger.error(f"Unable to configure switch defined in: {file_path}")
Expand All @@ -49,7 +49,7 @@ def load_preselector_from_file(preselector_config_file: Path):
preselector_config, PRESELECTOR_MODULE, PRESELECTOR_CLASS
)
except ConfigurationException:
logger.error(
logger.exception(
f"Unable to create preselector defined in: {preselector_config_file}"
)
return None
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/hardware/mocks/mock_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def acquire_time_domain_samples(
data_len = len(data)
if not len(data) == num_samples:
if retries > 0:
msg = "USRP error: requested {} samples, but got {}."
msg = "Signal analyzer error: requested {} samples, but got {}."
logger.warning(msg.format(num_samples + num_samples_skip, data_len))
logger.warning(f"Retrying {retries} more times.")
retries = retries - 1
Expand Down
8 changes: 4 additions & 4 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ def power_cycle_and_connect(self, sleep_time: float = 2.0) -> None:
try:
power_cycle_sigan()
except HardwareConfigurationException as hce:
logger.warn(f"Unable to power cycle sigan: {hce}")
logger.warning(f"Unable to power cycle sigan: {hce}")
return
try:
# Wait for power cycle to complete
logger.debug(f"Waiting {sleep_time} seconds before reconnecting...")
time.sleep(sleep_time)
logger.info("Power cycled signal analyzer. Reconnecting...")
self.connect()
except Exception as e:
logger.error(
f"Unable to reconnect to signal analyzer after power cycling: {e}"
except Exception:
logger.exception(
"Unable to reconnect to signal analyzer after power cycling"
)
return

Expand Down
2 changes: 1 addition & 1 deletion scos_actions/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger = logging.getLogger(__name__)
env = Env()

logger.info("Initializing scos-actions settings")
logger.debug("Initializing scos-actions settings")
CONFIG_DIR = Path(__file__).parent.resolve() / "configs"
ACTION_DEFINITIONS_DIR = CONFIG_DIR / "actions"

Expand Down
2 changes: 1 addition & 1 deletion scos_actions/status/status_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class StatusMonitor:
def __init__(self):
logger.info("Initializing StatusMonitor")
logger.debug("Initializing StatusMonitor")
self.status_components = []

def add_component(self, component):
Expand Down

0 comments on commit b33463a

Please sign in to comment.