Skip to content

Commit

Permalink
Reduce level of many log messages (#49)
Browse files Browse the repository at this point in the history
* Reduce level of many log messages

* Add more information to log messages

* Make log messages more descriptive

* Update pre-commit hooks

* autoformat files

* Bump patch version

* Reduce overload debug message level
  • Loading branch information
aromanielloNTIA committed Oct 27, 2023
1 parent 6fdcdcb commit f0f77a6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 23.10.0
rev: 23.10.1
hooks:
- id: black
types: [file, python]
Expand Down
2 changes: 1 addition & 1 deletion src/scos_tekrsa/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.1.4"
__version__ = "3.1.5"
8 changes: 5 additions & 3 deletions src/scos_tekrsa/discover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
logger = logging.getLogger(__name__)

actions = {}
logger.info("scos-tekrsa: discovering actions")
logger.debug("scos-tekrsa: discovering actions")
# Adjust ACTION_DEFINITIONS_DIR for specific Tektronix analyzer in use
if sigan:
logger.debug(f"Device Name: {sigan.device_name}")
Expand All @@ -25,7 +25,9 @@
]:
ACTION_DEFINITIONS_DIR = CONFIG_DIR / "actions-500-600"
else:
logger.error("Unable to determine RSA model")
logger.error(
"Unable to determine RSA model. Defaulting to use RSA500/600 action configs"
)
ACTION_DEFINITIONS_DIR = CONFIG_DIR / "actions-500-600"
logger.debug(f"Action configs directory: {ACTION_DEFINITIONS_DIR}")
actions["monitor_tekrsa"] = MonitorSignalAnalyzer(
Expand All @@ -38,7 +40,7 @@
logger.debug(f"Created {len(yaml_actions)} actions")
actions.update(yaml_actions)
else:
logger.warning("Sigan is null")
logger.warning("Sigan is None")


# Support status endpoint
Expand Down
2 changes: 1 addition & 1 deletion src/scos_tekrsa/hardware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

logger = logging.getLogger(__name__)
try:
logger.info(
logger.debug(
"*********************Creating TekRSASigan******************************"
)
sigan = TekRSASigan()
Expand Down
26 changes: 14 additions & 12 deletions src/scos_tekrsa/hardware/tekrsa_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TekRSASigan(SignalAnalyzerInterface):
def __init__(self):
try:
super().__init__()
logger.info("Initializing Tektronix RSA Signal Analyzer")
logger.debug("Initializing Tektronix RSA Signal Analyzer")
self._plugin_version = SCOS_TEKRSA_VERSION

self.rsa = None
Expand Down Expand Up @@ -49,7 +49,9 @@ def __init__(self):
self.connect()

except Exception as error:
logger.error(f"Unable to initialize sigan: {error}")
logger.error(
f"Unable to initialize sigan: {error}.\nAttempting to power cycle and reconnect..."
)
self.power_cycle_and_connect()

def get_constraints(self):
Expand All @@ -59,23 +61,23 @@ def get_constraints(self):
self.max_iq_bandwidth = self.rsa.IQSTREAM_GetMaxAcqBandwidth()

def connect(self):
logger.info("Connecting to TEKRSA")
logger.debug("Connecting to TEKRSA")
# Device already connected
if self._is_available:
return True

if settings.RUNNING_TESTS or settings.MOCK_SIGAN:
# Mock signal analyzer if desired
logger.warning("Using mock Tektronix RSA.")
logger.warning("Using mock Tektronix RSA signal analyzer.")
random = settings.MOCK_SIGAN_RANDOM
self.rsa = MockRSA(randomize_values=random)
else:
try:
# Load API wrapper
logger.info("Loading RSA API wrapper")
logger.debug("Loading RSA API wrapper")
import rsa_api
except ImportError as import_error:
logger.warning("API Wrapper not loaded - disabling signal analyzer.")
logger.exception("API Wrapper not loaded - disabling signal analyzer.")
self._is_available = False
raise import_error
try:
Expand All @@ -91,8 +93,8 @@ def connect(self):
# Finish setup with either real or Mock RSA device
self.device_name = self.rsa.DEVICE_GetNomenclature()
self.get_constraints()
logger.info("Using the following Tektronix RSA device:")
logger.info(
logger.debug("Using the following Tektronix RSA device:")
logger.debug(
f"{self.device_name} ({self.min_frequency}-{self.max_frequency} Hz)"
)
# Populate instance variables for parameters on connect
Expand Down Expand Up @@ -325,11 +327,11 @@ def acquire_time_domain_samples(
self.overload = False
if "Input overrange" in status:
self.overload = True
logger.warning("IQ stream: ADC overrange event occurred.")
logger.debug("IQ stream: ADC overrange event occurred.")

if "data loss" in status or "discontinuity" in status: # Invalid data
if retries > 0:
logger.warning(
logger.info(
f"Data loss occurred during IQ streaming. Retrying {retries} more times."
)
retries -= 1
Expand All @@ -343,8 +345,8 @@ def acquire_time_domain_samples(
): # Invalid data: incorrect number of samples
if retries > 0:
msg = f"RSA error: requested {nsamps_req + nskip} samples, but got {data_len}."
logger.warning(msg)
logger.warning(f"Retrying {retries} more times.")
logger.debug(msg)
logger.debug(f"Retrying {retries} more times.")
retries -= 1
continue
else:
Expand Down

0 comments on commit f0f77a6

Please sign in to comment.