Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
CHANGELOG
=========

# 2.2.0 / 2017-12-27
- [FEATURE] Set log level to warning for the datadog and request packages. See [#24][] (thanks to @n0ts)

# 2.1.0 / 2017-12-26
- [FEATURE] Disable callback if required python packages aren't installed. See [#28][] (thanks to @dobber)

Expand Down
15 changes: 15 additions & 0 deletions datadog_callback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import getpass
import os.path
import logging
import time

try:
Expand All @@ -21,6 +22,9 @@ def __init__(self):
print 'Datadog callback disabled.\nMake sure you call all required libraries: "datadog" and "yaml".'
else:
self.disabled = False
# Set logger level - datadog api and urllib3
for log_name in ['requests.packages.urllib3', 'datadog.api']:
self._set_logger_level(log_name)

self._playbook_name = None
self._start_time = time.time()
Expand All @@ -33,6 +37,17 @@ def __init__(self):
# self.play is set in the `playbook_on_play_start` callback method
self.play = None

# Set logger level
def _set_logger_level(self, name, level=logging.WARNING):
try:
log = logging.getLogger(name)
log.setLevel(level)
log.propagate = False
except Exception, e:
# We don't want Ansible to fail on an API error
print 'Couldn\'t get logger - %s' % name
print e

# Load parameters from conf file
def _load_conf(self, file_path):
conf_dict = {}
Expand Down