Open alikins opened 7 years ago
What is this status of this proposal? I have third party Python modules using the logger class that I am trying to wrap Ansible around and have no idea how to set up or configure so that Ansible will get those logger messages written somewhere. The proposal opening says there is a "working prototype", is there something I can use to help validate third party code using logger class can be configured and work inside and Ansible playbook?
I am wondering how many years do we need until Ansible logging would be done right. As of today, even the latest 2.13.1 does enforce wrapping of warnings, which hinders console display and makes impossible to process the output. Effectively making it worse for both humans and machines.
@cidrblock Maybe we can push a little bit more to sort this out? That bug alone hinders usability our most development tools
@ssbarnea 'done right' has many different opinions, this proposal has been discussed many times always ending in an impasse.
While the core team now has more consensus on the approach going forward, it still needs to be backwards compatible with the current 'display', otherwise all 3rd party plugins using it would cease to function.
In any case, if you want to bring it up for further discussion, we have monthly IRC meetings exactly for this purpose. https://github.com/ansible/community/issues?q=is%3Aissue+is%3Aopen+label%3Acore+label%3Ameeting_agenda
FYI, this is not a bug, it is a proposal
Proposal: Use python stdlib logging
Author: Adrian Likins alikins@redhat.com
Date: 2016-10-10
Motivation
Python stdlib logging is a well known and common approach to logging, with a flexible and extensible configuration, wide 3rd party vendor support, and offers integration with common python modules.
Problems
What problems exist that this proposal will solve?
Solution proposal
log.debug('template=%s', template)
would never need to str/repr(template) if the handlers log level is 'INFO'Example logging use
Output with added context info:
log.exception() example on a playbook yaml parsing error
Same example using a 3rd party json logging formatter (logomatic.JsonFormatter in this case)
An example of a debug log with contextual info about remote hosts being targetted:
Dependencies (optional)
For basic use, there are no external dependencies. The 'logging' module exists in all python versions supported. For concurrent logging to a single file, the 'multiprocess' module is required.
Additional log handlers, formatters, and filters may have additional deps. For example, log handlers for logging to 3rd party cloud based logging services may need 'requests' or a app specific dep.
If a yaml based logging config supports is needed on py2.6, a backport of 2.7's 'logging.dictConfig' may be needed.
Testing (optional)
Logging focused testing is recommended.
Additionally it will be useful to include tests that compare old style display based logging output to 'logging' output.
Testing of an assortment of logging configurations is recommended (custom formats, custom handlers, logging to syslog/journal/etc). Testing of log file handling and rotation. Testing of multiprocess concurrency correctness and stability.
Documentation (optional)
This will need user and developer focused documentation.
Users will have significant logging options available. Examples configurations of some common cases (file logging, syslog, journald, remote logging, ELK stack, etc).
Developers will need documentation on proper use of 'logging' module (although the module is well documented elsewhere). This will include any ansible specific changes (our handlers, formatters, filters, and adapters will need documentation on their use).
Anything else?
Related: