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

Created new module labrad.logging to unify and streamline logging process #394

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

clayton-ho
Copy link

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).

…d library

moved node/__init__.py from twisted.python.usage to argparse in python standard library for parsing CLI arguments

added support for rfc5424 syslog protocol as well as regular rfc3164 protocol

added labrad.logging module to streamline and simplify the process of setting up logging
@clayton-ho clayton-ho changed the title Cho/logging Created new module labrad.logging to unify and streamline logging process Jul 9, 2022
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.

None yet

1 participant