Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logging module instead of prints #345

Merged
merged 12 commits into from
Nov 15, 2024

Conversation

nfelt14
Copy link
Collaborator

@nfelt14 nfelt14 commented Nov 9, 2024

Proposed changes

This switches tm_devices to use logging instead of normal printing. A new function, configure_logging() is provided so that users can configure what is being logged where. The default behavior keeps the stdout output very similar and adds a file log that contains all logging output.

The log file also can be configured to including the debug output from pyvisa, since that library is crucial to debugging issues connecting to devices.
 
Addresses #319 and #316

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Functionality update (non-breaking change which updates or changes existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (an update to enhance the user experience when reading through the docs)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have followed the guidelines in the CONTRIBUTING document
  • I have signed the CLA
  • I have checked to ensure there aren't other open Pull Requests for the same update/change
  • I have created (or updated) an Issue to track the status of this update/change and updated the link in this PR description (see above in the Proposed changes section) using the wording Addresses #<issue_number>
  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • Basic linting passes locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added necessary documentation (if appropriate)
  • I have updated the Changelog with a brief description of my changes

…formation to stdout.

This provides users with more control over stdout and also allows for logging outputs to files.
Also updated the tests to work properly with the new logging
Copy link

codecov bot commented Nov 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1fddc6c) to head (c7348a5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #345   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          160       161    +1     
  Lines         4547      4645   +98     
  Branches       799       777   -22     
=========================================
+ Hits          4547      4645   +98     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nfelt14
Copy link
Collaborator Author

nfelt14 commented Nov 9, 2024

Things still needing to be added:

  • documentation
  • examples of configuration and using custom loggers
  • configuration via environment variable and config file

src/tm_devices/helpers/constants_and_dataclasses.py Dismissed Show dismissed Hide dismissed
src/tm_devices/helpers/logging.py Dismissed Show dismissed Hide dismissed
@nfelt14 nfelt14 marked this pull request as ready for review November 12, 2024 04:21
@nfelt14 nfelt14 requested review from a team as code owners November 12, 2024 04:21
tests/test_logging.py Dismissed Show dismissed Hide dismissed
michaelwagoner
michaelwagoner previously approved these changes Nov 12, 2024
src/tm_devices/helpers/logging.py Show resolved Hide resolved
ldantek
ldantek previously approved these changes Nov 13, 2024
…i-line VISA write.

Also updated unit test simulated devices and locked the version of pyright.
Copy link

github-actions bot commented Nov 15, 2024

Breaking API Changes

src/tm_devices/driver_mixins/device_control/pi_control.py:218: PIControl.check_visa_connection(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/pi_control.py:772: PIControl.wait_for_visa_connection(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:73: RESTAPIControl.delete(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:113: RESTAPIControl.get(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:153: RESTAPIControl.patch(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:202: RESTAPIControl.post(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:251: RESTAPIControl.put(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:299: RESTAPIControl.set_api_version(verbose):
Parameter was removed

src/tm_devices/driver_mixins/device_control/rest_api_control.py:313: RESTAPIControl.wait_for_api_connection(verbose):
Parameter was removed

src/tm_devices/drivers/device.py:368: Device.check_network_connection(verbose):
Parameter was removed

src/tm_devices/drivers/device.py:381: Device.check_port_connection(verbose):
Parameter was removed

src/tm_devices/drivers/device.py:480: Device.wait_for_network_connection(verbose):
Parameter was removed

src/tm_devices/drivers/device.py:541: Device.wait_for_port_connection(verbose):
Parameter was removed

src/tm_devices/helpers/functions.py:217: check_network_connection(verbose):
Parameter was removed

src/tm_devices/helpers/functions.py:238: check_port_connection(verbose):
Parameter was removed

src/tm_devices/helpers/functions.py:267: check_visa_connection(verbose):
Parameter was removed

src/tm_devices/helpers/__init__.py:0: get_timestamp_string:
Public object was removed

src/tm_devices/helpers/__init__.py:0: print_with_timestamp:
Public object was removed

src/tm_devices/helpers/functions.py:0: get_timestamp_string:
Public object was removed

src/tm_devices/helpers/functions.py:0: print_with_timestamp:
Public object was removed

Link to workflow run

Copy link

github-actions bot commented Nov 15, 2024

Test Results (windows)

path passed subtotal
tests\test_afgs.py 2 2
tests\test_alias_dict.py 1 1
tests\test_all_device_drivers.py 101 101
tests\test_alternative_connection_addresses.py 19 19
tests\test_awgs.py 4 4
tests\test_config_parser.py 40 40
tests\test_device_manager.py 17 17
tests\test_devices_legacy_tsp_ieee_cmds.py 3 3
tests\test_extension_mixin.py 1 1
tests\test_generate_waveform.py 6 6
tests\test_helpers.py 72 72
tests\test_ieee_scpi_cmds.py 1 1
tests\test_logging.py 4 4
tests\test_margin_testers.py 5 5
tests\test_pi_device.py 1 1
tests\test_psu.py 1 1
tests\test_rest_api_device.py 10 10
tests\test_scopes.py 9 9
tests\test_singleton.py 1 1
tests\test_smu.py 4 4
tests\test_ss.py 1 1
tests\test_tm_devices.py 425 425
tests\test_unsupported_device_type.py 1 1
tests\test_verification_functions.py 6 6
TOTAL 735 735

Link to workflow run

Copy link

github-actions bot commented Nov 15, 2024

Test Results (macos)

path passed subtotal
tests/test_afgs.py 2 2
tests/test_alias_dict.py 1 1
tests/test_all_device_drivers.py 101 101
tests/test_alternative_connection_addresses.py 19 19
tests/test_awgs.py 4 4
tests/test_config_parser.py 40 40
tests/test_device_manager.py 17 17
tests/test_devices_legacy_tsp_ieee_cmds.py 3 3
tests/test_extension_mixin.py 1 1
tests/test_generate_waveform.py 6 6
tests/test_helpers.py 72 72
tests/test_ieee_scpi_cmds.py 1 1
tests/test_logging.py 4 4
tests/test_margin_testers.py 5 5
tests/test_pi_device.py 1 1
tests/test_psu.py 1 1
tests/test_rest_api_device.py 10 10
tests/test_scopes.py 9 9
tests/test_singleton.py 1 1
tests/test_smu.py 4 4
tests/test_ss.py 1 1
tests/test_tm_devices.py 425 425
tests/test_unsupported_device_type.py 1 1
tests/test_verification_functions.py 6 6
TOTAL 735 735

Link to workflow run

Copy link

github-actions bot commented Nov 15, 2024

Test Results (ubuntu)

path passed subtotal
tests/test_afgs.py 2 2
tests/test_alias_dict.py 1 1
tests/test_all_device_drivers.py 101 101
tests/test_alternative_connection_addresses.py 19 19
tests/test_awgs.py 4 4
tests/test_config_parser.py 40 40
tests/test_device_manager.py 17 17
tests/test_devices_legacy_tsp_ieee_cmds.py 3 3
tests/test_extension_mixin.py 1 1
tests/test_generate_waveform.py 6 6
tests/test_helpers.py 72 72
tests/test_ieee_scpi_cmds.py 1 1
tests/test_logging.py 4 4
tests/test_margin_testers.py 5 5
tests/test_pi_device.py 1 1
tests/test_psu.py 1 1
tests/test_rest_api_device.py 10 10
tests/test_scopes.py 9 9
tests/test_singleton.py 1 1
tests/test_smu.py 4 4
tests/test_ss.py 1 1
tests/test_tm_devices.py 425 425
tests/test_unsupported_device_type.py 1 1
tests/test_verification_functions.py 6 6
TOTAL 735 735

Link to workflow run

@nfelt14 nfelt14 merged commit aa68ea4 into tektronix:main Nov 15, 2024
71 checks passed
@nfelt14 nfelt14 deleted the use-logging-instead-of-prints branch November 15, 2024 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants