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

Add a callback that uses python logging #25767

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
7 participants
@alikins
Contributor

alikins commented Jun 15, 2017

SUMMARY

Add a callback that uses python logging

This also attempts to track playbook/play/task context so it can be provided to log handlers and formatters.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/plugins/callback/stdlog.py

ANSIBLE VERSION
ansible 2.4.0 (stdlog_callback_new fbe2123aae) last updated 2017/06/15 15:09:38 (GMT -400)
  config file = None
  configured module search path = [u'/home/adrian/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/adrian/src/ansible/lib/ansible
  executable location = /home/adrian/src/ansible/bin/ansible
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

ADDITIONAL INFORMATION

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jun 15, 2017

The test ansible-test sanity --test pep8 failed with the following errors:

lib/ansible/cli/__init__.py:286:17: E261 at least two spaces before inline comment
lib/ansible/cli/__init__.py:286:18: E262 inline comment should start with '# '
lib/ansible/plugins/callback/stdlog.py:41:161: E501 line too long (228 > 160 characters)
lib/ansible/plugins/callback/stdlog.py:187:5: E265 block comment should start with '# '
lib/ansible/plugins/vars/host_group_vars.py:124:42: E261 at least two spaces before inline comment
lib/ansible/plugins/vars/host_group_vars.py:129:58: E261 at least two spaces before inline comment

click here for bot help

@ansibot

This comment has been minimized.

Contributor

ansibot commented Jun 16, 2017

The test ansible-test sanity --test pep8 failed with the following errors:

lib/ansible/plugins/callback/stdlog.py:41:161: E501 line too long (228 > 160 characters)
lib/ansible/plugins/callback/stdlog.py:187:5: E265 block comment should start with '# '

click here for bot help

@alikins alikins force-pushed the alikins:stdlog_callback_new branch to e6c3e0a Jul 11, 2017

@alikins

This comment has been minimized.

Contributor

alikins commented Jul 12, 2017

test comment

@mattclay

This comment has been minimized.

Member

mattclay commented Jul 14, 2017

CI failure in integration tests: https://app.shippable.com/github/ansible/ansible/runs/28469/40/console

The relevant error appears to be:

2017-07-13 04:27:25 Missing MAGICKEYWORD in output.

@ansibot ansibot added the stale_ci label Jul 22, 2017

# this plugin, just set ANSIBLE_LOG_PATH as an environment variable
# or log_path in the DEFAULTS section of your ansible configuration
# file. This callback is an example of per hosts logging for those
# that want it.

This comment has been minimized.

@abadger

abadger Aug 7, 2017

Member

is this comment right?

# from ansible.utils.unicode import to_bytes
from ansible.plugins.callback import CallbackBase
# import logging_tree

This comment has been minimized.

@abadger

abadger Aug 7, 2017

Member

Go ahead and remove the commented out imports

# file. This callback is an example of per hosts logging for those
# that want it.
DEBUG_LOG_FORMAT = "%(asctime)s [%(name)s %(levelname)s %(hostname)s %(playbook)s] pid=%(process)d %(funcName)s:%(lineno)d - %(message)s"

This comment has been minimized.

@bcoca

bcoca Sep 15, 2017

Member

I would make these configurable options, by adding them as options to DOCUMENTATION entry you can then use self._plugin_options['optionname'] to access them

This comment has been minimized.

@bcoca

bcoca Sep 15, 2017

Member

also .. add DOCUMENTATION entry

@@ -0,0 +1,395 @@
# (C) 2012, Michael DeHaan, <michael.dehaan@gmail.com>

This comment has been minimized.

@bcoca

bcoca Sep 15, 2017

Member

use new short Copyright/license

@bcoca

This comment has been minimized.

Member

bcoca commented Sep 15, 2017

I woudl also make this take over for the current 'ansbile_log'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment