Created new module labrad.logging to unify and streamline logging process #394
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completely moves logging from twisted.python.log to labrad.logging module that builds on top of the logging module in the python standard library. This reduces the dependency on twisted, especially its logging modules, which have been legacy for some time. Additionally, since much of the node configuration in node/init.py was for setting up logging, the CLI interface has been moved from twisted.python.usage.Options to the more well-supported and user-friendly argparse module, also from the python standard library.
Setup of a logger can now be done using a call to labrad.logging.setupLogging, which returns a logger configured for the caller object. Problems with duplicate and unwanted logs (which are common nuisances when using multiple modules which separately do logging) are guarded against by ensuring that any log handlers are only set once.
Previously, print statements were diverted to the logger, and log output would in turn be displayed in stdout - this feature is maintained. Logging to logfiles and syslog (both RFC5424 and RFC3164) are supported, with RFC5424 syslog support enabled by adding another dependency (rfc5424-logging-handler). The addition of RFC5424 support allows the use of most standard log management systems, such as Prometheus or Grafana Loki.
Hopefully, logging should now be more robust and usable, such that users can easily implement it in their own classes (e.g. GUI clients, experiment classes).