code: def make_file_object_logger(fh):
      
      def logger_func(stmt, args, fh=fh):
          """
          A logger that logs everything sent to a file object.
          """
          now = datetime.datetime.now()
          six.print_("Executing (%s):" % now.isoformat(), file=fh)
          six.print_(textwrap.dedent(stmt), file=fh)
          six.print_("Arguments:", file=fh)
          pprint.pprint(args, fh)
      return logger_func
docs: Make a logger that logs to the given file object.