xolox/python-verboselogs

log record funcName is not set correctly

glennmatthews opened this issue · 0 comments

LogRecords created by the new log commands have their funcName field set to the name of the log function, rather than the function calling it:

def tar(...)
            for file_obj in self.references.findall(self.FILE):
                file_name = file_obj.get(self.FILE_HREF)
                file_ref = self._file_references[file_name]
                file_ref.add_to_archive(tarf)
                logger.verbose("Added %s to %s", file_name, tar_file)

Expected output:

    INFO: add_to_archive         Adding COT/tests/input.vmdk to TAR file as input.vmdk
 VERBOSE: tar                    Added input.vmdk to temp.ova
    INFO: add_to_archive         Adding COT/tests/input.iso to TAR file as input.iso
 VERBOSE: tar                    Added input.iso to temp.ova
    INFO: add_to_archive         Adding COT/tests/sample_cfg.txt to TAR file as sample_cfg.txt

Actual output:

    INFO: add_to_archive         Adding COT/tests/input.vmdk to TAR file as input.vmdk
 VERBOSE: verbose                Added input.vmdk to temp.ova
    INFO: add_to_archive         Adding COT/tests/input.iso to TAR file as input.iso
 VERBOSE: verbose                Added input.iso to temp.ova
    INFO: add_to_archive         Adding COT/tests/sample_cfg.txt to TAR file as sample_cfg.txt

Looking at https://hg.python.org/cpython/file/2.7/Lib/logging/__init__.py, the fix for this might be changing the VerboseLogger implementation to call _log instead of log, as in:

    def verbose(self, *args, **kw):
        """Log a message with level :data:`VERBOSE`. The arguments are interpreted as for :func:`logging.debug()`."""
        if self.isEnabledFor(VERBOSE):
            self._log(VERBOSE, *args, **kw)