docs: def format_log(ret):
      '''
      Format the state into a log message
      '''
      msg = ''
      if isinstance(ret, dict):
          # Looks like the ret may be a valid state return
          if 'changes' in ret:
              # Yep, looks like a valid state return
              chg = ret['changes']
              if not chg:
                  if ret['comment']:
                      msg = ret['comment']
                  else:
                      msg = 'No changes made for {0[name]}'.format(ret)
              elif isinstance(chg, dict):
                  if 'diff' in chg:
                      if isinstance(chg['diff'], six.string_types):
                          msg = 'File changed:\n{0}'.format(chg['diff'])
                  if all([isinstance(x, dict) for x in six.itervalues(chg)]):
                      if all([('old' in x and 'new' in x)
                              for x in six.itervalues(chg)]):
                          msg = 'Made the following changes:\n'
                          for pkg in chg:
                              old = chg[pkg]['old']
                              if not old and old not in (False, None):
                                  old = 'absent'
                              new = chg[pkg]['new']
                              if not new and new not in (False, None):
                                  new = 'absent'
                              # This must be able to handle unicode as some package names contain
                              # non-ascii characters like "Français" or "Español". See Issue #33605.
                              msg += '\'{0}\' changed from \'{1}\' to \'{2}\'\n'.format(pkg, old, new)
              if not msg:
                  msg = six.text_type(ret['changes'])
              if ret['result'] is True or ret['result'] is None:
                  log.info(msg)
              else:
                  log.error(msg)
      else:
          # catch unhandled data
          log.info(six.text_type(ret))