created debug method, renamed debug attribute to _debug

This commit is contained in:
Brian Coca 2015-10-01 00:09:15 -04:00
parent deff045aa9
commit 1a56a5c442

View file

@ -428,7 +428,7 @@ class AnsibleModule(object):
self.check_mode = False self.check_mode = False
self.no_log = no_log self.no_log = no_log
self.cleanup_files = [] self.cleanup_files = []
self.debug = False self._debug = False
self.aliases = {} self.aliases = {}
@ -1001,7 +1001,7 @@ class AnsibleModule(object):
self.no_log = self.boolean(v) self.no_log = self.boolean(v)
elif k == '_ansible_debug': 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: elif check_invalid_arguments and k not in self._legal_inputs:
self.fail_json(msg="unsupported parameter for module: %s" % k) 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.openlog(str(module), 0, syslog.LOG_USER)
syslog.syslog(syslog.LOG_INFO, msg) syslog.syslog(syslog.LOG_INFO, msg)
def debug(self, msg):
if self._debug:
self.log(msg)
def log(self, msg, log_args=None): def log(self, msg, log_args=None):
if not self.no_log: if not self.no_log:
@ -1701,7 +1705,7 @@ class AnsibleModule(object):
try: try:
if self.debug: if self._debug:
if isinstance(args, list): if isinstance(args, list):
running = ' '.join(args) running = ' '.join(args)
else: else: