From 1a56a5c442a6c9656acd2be1c732e1fb30855a17 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 1 Oct 2015 00:09:15 -0400 Subject: [PATCH] created debug method, renamed debug attribute to _debug --- lib/ansible/module_utils/basic.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index b1af1164b42..cb61f3da7b6 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -428,7 +428,7 @@ class AnsibleModule(object): self.check_mode = False self.no_log = no_log self.cleanup_files = [] - self.debug = False + self._debug = False self.aliases = {} @@ -1001,7 +1001,7 @@ class AnsibleModule(object): self.no_log = self.boolean(v) elif k == '_ansible_debug': - self.debug = self.boolean(v) + self._debug = self.boolean(v) elif check_invalid_arguments and k not in self._legal_inputs: self.fail_json(msg="unsupported parameter for module: %s" % k) @@ -1250,6 +1250,10 @@ class AnsibleModule(object): syslog.openlog(str(module), 0, syslog.LOG_USER) syslog.syslog(syslog.LOG_INFO, msg) + def debug(self, msg): + if self._debug: + self.log(msg) + def log(self, msg, log_args=None): if not self.no_log: @@ -1680,7 +1684,7 @@ class AnsibleModule(object): close_fds=close_fds, stdin=st_in, stdout=subprocess.PIPE, - stderr=subprocess.PIPE + stderr=subprocess.PIPE ) if path_prefix: @@ -1701,7 +1705,7 @@ class AnsibleModule(object): try: - if self.debug: + if self._debug: if isinstance(args, list): running = ' '.join(args) else: