def _log_invocation(self):
        ''' log that ansible ran the module '''
        # TODO: generalize a separate log function and make log_invocation use it
        # Sanitize possible password argument when logging.
        log_args = dict()
        passwd_keys = ['password', 'login_password']

        filter_re = [
            # filter out things like user:pass@foo/whatever
            # and http://username:pass@wherever/foo
            re.compile('^(?P<before>.*:)(?P<password>.*)(?P<after>\@.*)$'), 
        ]

        for param in self.params:
            canon  = self.aliases.get(param, param)
            arg_opts = self.argument_spec.get(canon, {})
            no_log = arg_opts.get('no_log', False)
                
            if no_log:
                log_args[param] = 'NOT_LOGGING_PARAMETER'
            elif param in passwd_keys:
                log_args[param] = 'NOT_LOGGING_PASSWORD'
            else:
                found = False
                for filter in filter_re:
                    if isinstance(self.params[param], unicode):
                        m = filter.match(self.params[param])
                    else:
                        m = filter.match(str(self.params[param]))
                    if m:
                        d = m.groupdict()
                        log_args[param] = d['before'] + "********" + d['after']
                        found = True
                        break
                if not found:
                    log_args[param] = self.params[param]

        module = 'ansible-%s' % os.path.basename(__file__)
        msg = ''
        for arg in log_args:
            if isinstance(log_args[arg], basestring):
                msg = msg + arg + '=' + log_args[arg].decode('utf-8') + ' '
            else:
                msg = msg + arg + '=' + str(log_args[arg]) + ' '
        if msg:
            msg = 'Invoked with %s' % msg
        else:
            msg = 'Invoked'

        # 6655 - allow for accented characters
        try:
            msg = msg.encode('utf8')
        except UnicodeDecodeError, e:
            pass

        if (has_journal):
            journal_args = ["MESSAGE=%s %s" % (module, msg)]
            journal_args.append("MODULE=%s" % os.path.basename(__file__))
            for arg in log_args:
                journal_args.append(arg.upper() + "=" + str(log_args[arg]))
            try:
                journal.sendv(*journal_args)
            except IOError, e:
                # fall back to syslog since logging to journal failed
                syslog.openlog(str(module), 0, syslog.LOG_USER)
                syslog.syslog(syslog.LOG_NOTICE, msg) #1
        else:
            syslog.openlog(str(module), 0, syslog.LOG_USER)
            syslog.syslog(syslog.LOG_NOTICE, msg) #2
dataset/ETHPy150Open glenjarvis/ansible_tutorial/src/example_03/ansible_module.py/AnsibleModule._log_invocation/original