forked from tektronix/tm_devices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use logging module instead of prints (tektronix#345)
* docs: Update link to badge * feat: Switched to using the Python logging module for printing out information to stdout. This provides users with more control over stdout and also allows for logging outputs to files. * feat: Added the pyvisa log to the file. Also updated the tests to work properly with the new logging * feat: Added individual VISA command logging for each VISA device. * refactor: Update linting settings and update code to use Path objects instead of builtins where possible. * docs: Updated documentation with instructions and examples on how to configure logging. * refactor: Update code based on Pull Request build failures * test: Add tests for the logging configuration function. * docs: Update IP addresses used in examples * test: Update some tests to be less flaky * refactor: Add leading tabs to the standard logging output of the multi-line VISA write. Also updated unit test simulated devices and locked the version of pyright.
- Loading branch information
Showing
85 changed files
with
1,161 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""The console output and level of logging outputs in the log file can be configured as needed.""" | ||
|
||
from tm_devices import configure_logging, DeviceManager, LoggingLevels | ||
from tm_devices.drivers import MSO6B | ||
|
||
# NOTE: This configuration will prevent any logging config options from a config file or | ||
# environment variable from being used. | ||
configure_logging( | ||
log_console_level=LoggingLevels.NONE, # completely disable console logging | ||
log_file_level=LoggingLevels.DEBUG, # log everything to the file | ||
log_file_directory="./log_files", # save the log file in the "./log_files" directory | ||
log_file_name="custom_log_filename.log", # customize the filename | ||
log_pyvisa_messages=True, # include all the pyvisa debug messages in the same log file | ||
) | ||
|
||
with DeviceManager(verbose=False) as dm: | ||
scope: MSO6B = dm.add_scope("192.168.0.1") | ||
scope.curve_query(1) | ||
scope.check_port_connection(4000) | ||
scope.check_network_connection() | ||
scope.check_visa_connection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.