[diffoscope] 01/02: Use more-Python logging functions based on __name__, etc.
Chris Lamb
chris at chris-lamb.co.uk
Tue Jan 3 12:09:47 CET 2017
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit 356b1886451cbe0a91d37da807587f9f321d636e
Author: Chris Lamb <lamby at debian.org>
Date: Tue Jan 3 11:06:45 2017 +0000
Use more-Python logging functions based on __name__, etc.
Signed-off-by: Chris Lamb <lamby at debian.org>
---
diffoscope/changes.py | 4 +++-
diffoscope/comparators/apk.py | 5 ++++-
diffoscope/comparators/ar.py | 4 +++-
diffoscope/comparators/bzip2.py | 4 +++-
diffoscope/comparators/cbfs.py | 4 +++-
diffoscope/comparators/deb.py | 4 +++-
diffoscope/comparators/debian.py | 4 +++-
diffoscope/comparators/dex.py | 4 +++-
diffoscope/comparators/directory.py | 4 +++-
diffoscope/comparators/elf.py | 4 +++-
diffoscope/comparators/fsimage.py | 4 +++-
diffoscope/comparators/gettext.py | 4 +++-
diffoscope/comparators/gzip.py | 4 +++-
diffoscope/comparators/haskell.py | 4 +++-
diffoscope/comparators/missing_file.py | 4 +++-
diffoscope/comparators/ppu.py | 4 +++-
diffoscope/comparators/ps.py | 4 +++-
diffoscope/comparators/rpm.py | 4 +++-
diffoscope/comparators/rust.py | 4 +++-
diffoscope/comparators/squashfs.py | 4 +++-
diffoscope/comparators/symlink.py | 4 +++-
diffoscope/comparators/utils/archive.py | 4 +++-
diffoscope/comparators/utils/command.py | 3 ++-
diffoscope/comparators/utils/compare.py | 4 +++-
diffoscope/comparators/utils/container.py | 3 ++-
diffoscope/comparators/utils/file.py | 4 +++-
diffoscope/comparators/utils/fuzzy.py | 4 +++-
diffoscope/comparators/utils/libarchive.py | 4 +++-
diffoscope/comparators/utils/specialize.py | 4 +++-
diffoscope/comparators/xz.py | 4 +++-
diffoscope/difference.py | 4 +++-
diffoscope/locale.py | 3 ++-
diffoscope/logging.py | 18 +++++++++++-------
diffoscope/main.py | 8 +++++---
diffoscope/presenters/html/html.py | 4 +++-
diffoscope/presenters/text.py | 4 +++-
diffoscope/presenters/utils.py | 4 +++-
diffoscope/tempfiles.py | 5 +++--
38 files changed, 122 insertions(+), 47 deletions(-)
diff --git a/diffoscope/changes.py b/diffoscope/changes.py
index 3e5ee75..95dccaf 100644
--- a/diffoscope/changes.py
+++ b/diffoscope/changes.py
@@ -43,12 +43,14 @@ __license__ = 'MIT'
import os.path
import hashlib
+import logging
import subprocess
from debian import deb822
from .tools import tool_required
-from .logging import logger
+
+logger = logging.getLogger(__name__)
class ChangesFileException(Exception):
diff --git a/diffoscope/comparators/apk.py b/diffoscope/comparators/apk.py
index d8f8ca4..3d43115 100644
--- a/diffoscope/comparators/apk.py
+++ b/diffoscope/comparators/apk.py
@@ -19,15 +19,18 @@
import re
import os.path
+import logging
import subprocess
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.tempfiles import get_temporary_directory
from .utils.file import File
from .utils.archive import Archive
+logger = logging.getLogger(__name__)
+
+
class ApkContainer(Archive):
@property
def path(self):
diff --git a/diffoscope/comparators/ar.py b/diffoscope/comparators/ar.py
index dfb6665..a8634ee 100644
--- a/diffoscope/comparators/ar.py
+++ b/diffoscope/comparators/ar.py
@@ -19,15 +19,17 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
+import logging
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.file import File
from .utils.command import Command
from .utils.libarchive import LibarchiveContainer, list_libarchive
+logger = logging.getLogger(__name__)
+
# TODO: this would also be useful for Go archives. Currently those are handled
# by StaticLibFile, but then readelf complains with "Error: Not an ELF file".
diff --git a/diffoscope/comparators/bzip2.py b/diffoscope/comparators/bzip2.py
index a4c99f9..aac1999 100644
--- a/diffoscope/comparators/bzip2.py
+++ b/diffoscope/comparators/bzip2.py
@@ -19,16 +19,18 @@
import re
import os.path
+import logging
import subprocess
import collections
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from .utils.file import File
from .utils.archive import Archive
from .utils.filenames import get_compressed_content_name
+logger = logging.getLogger(__name__)
+
class Bzip2Container(Archive):
def open_archive(self):
diff --git a/diffoscope/comparators/cbfs.py b/diffoscope/comparators/cbfs.py
index ee48769..0002bbb 100644
--- a/diffoscope/comparators/cbfs.py
+++ b/diffoscope/comparators/cbfs.py
@@ -21,16 +21,18 @@ import io
import os
import re
import struct
+import logging
import subprocess
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.file import File
from .utils.archive import Archive
from .utils.command import Command
+logger = logging.getLogger(__name__)
+
class CbfsListing(Command):
def __init__(self, *args, **kwargs):
diff --git a/diffoscope/comparators/deb.py b/diffoscope/comparators/deb.py
index fcf342b..95fb992 100644
--- a/diffoscope/comparators/deb.py
+++ b/diffoscope/comparators/deb.py
@@ -18,8 +18,8 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
+import logging
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .tar import TarContainer
@@ -33,6 +33,8 @@ try:
except ImportError:
deb822 = None
+logger = logging.getLogger(__name__)
+
# Return a dict with build ids as keys and file as values for all deb in the
# given container
diff --git a/diffoscope/comparators/debian.py b/diffoscope/comparators/debian.py
index b42bb0a..c3a1ea4 100644
--- a/diffoscope/comparators/debian.py
+++ b/diffoscope/comparators/debian.py
@@ -20,12 +20,12 @@
import re
import os.path
import hashlib
+import logging
import functools
import collections
from debian.deb822 import Dsc
-from diffoscope.logging import logger
from diffoscope.changes import Changes
from diffoscope.difference import Difference
@@ -40,6 +40,8 @@ DOT_CHANGES_FIELDS = [
"Changes",
]
+logger = logging.getLogger(__name__)
+
class DebControlMember(File):
def __init__(self, container, member_name):
diff --git a/diffoscope/comparators/dex.py b/diffoscope/comparators/dex.py
index 966d3f5..37b53c7 100644
--- a/diffoscope/comparators/dex.py
+++ b/diffoscope/comparators/dex.py
@@ -19,16 +19,18 @@
import re
import os.path
+import logging
import subprocess
import collections
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from .utils.file import File
from .utils.archive import Archive
from .utils.filenames import get_compressed_content_name
+logger = logging.getLogger(__name__)
+
class DexContainer(Archive):
@property
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index 6a4cee1..59a9029 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -19,11 +19,11 @@
import os
import re
+import logging
import subprocess
from diffoscope.exc import RequiredToolNotFound
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.progress import Progress
from diffoscope.difference import Difference
@@ -31,6 +31,8 @@ from .binary import FilesystemFile
from .utils.command import Command
from .utils.container import Container
+logger = logging.getLogger(__name__)
+
def list_files(path):
path = os.path.realpath(path)
diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index a3a65b7..dc8a386 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -19,12 +19,12 @@
import os
import re
+import logging
import subprocess
import collections
from diffoscope.exc import OutputParsingError
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.tempfiles import get_named_temporary_file
from diffoscope.difference import Difference
@@ -51,6 +51,8 @@ DEBUG_SECTION_GROUPS = (
'gdb_index',
)
+logger = logging.getLogger(__name__)
+
class Readelf(Command):
def __init__(self, *args, **kwargs):
diff --git a/diffoscope/comparators/fsimage.py b/diffoscope/comparators/fsimage.py
index e6ad952..ed324b0 100644
--- a/diffoscope/comparators/fsimage.py
+++ b/diffoscope/comparators/fsimage.py
@@ -18,10 +18,10 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
+import logging
import os.path
import collections
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.file import File
@@ -32,6 +32,8 @@ try:
except ImportError:
guestfs = None
+logger = logging.getLogger(__name__)
+
class FsImageContainer(Archive):
def open_archive(self):
diff --git a/diffoscope/comparators/gettext.py b/diffoscope/comparators/gettext.py
index c6a75a7..37b8556 100644
--- a/diffoscope/comparators/gettext.py
+++ b/diffoscope/comparators/gettext.py
@@ -19,14 +19,16 @@
import io
import re
+import logging
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.file import File
from .utils.command import Command
+logger = logging.getLogger(__name__)
+
class Msgunfmt(Command):
CHARSET_RE = re.compile(rb'^"Content-Type: [^;]+; charset=([^\\]+)\\n"$')
diff --git a/diffoscope/comparators/gzip.py b/diffoscope/comparators/gzip.py
index dde67e7..f3a1d1a 100644
--- a/diffoscope/comparators/gzip.py
+++ b/diffoscope/comparators/gzip.py
@@ -19,16 +19,18 @@
import re
import os.path
+import logging
import subprocess
import collections
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.archive import Archive
from .utils.filenames import get_compressed_content_name
+logger = logging.getLogger(__name__)
+
class GzipContainer(Archive):
def open_archive(self):
diff --git a/diffoscope/comparators/haskell.py b/diffoscope/comparators/haskell.py
index 8213447..6a1ac6c 100644
--- a/diffoscope/comparators/haskell.py
+++ b/diffoscope/comparators/haskell.py
@@ -19,17 +19,19 @@
import re
import struct
+import logging
import platform
import subprocess
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.profiling import profile
from diffoscope.difference import Difference
from .utils.file import File
from .utils.command import Command
+logger = logging.getLogger(__name__)
+
class ShowIface(Command):
@tool_required('ghc')
diff --git a/diffoscope/comparators/missing_file.py b/diffoscope/comparators/missing_file.py
index 3ca40d7..86cb5c7 100644
--- a/diffoscope/comparators/missing_file.py
+++ b/diffoscope/comparators/missing_file.py
@@ -18,14 +18,16 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
+import logging
from diffoscope.config import Config
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .binary import FilesystemFile
from .utils.file import File
+logger = logging.getLogger(__name__)
+
class MissingFile(File):
"""
diff --git a/diffoscope/comparators/ppu.py b/diffoscope/comparators/ppu.py
index 21219e1..3370236 100644
--- a/diffoscope/comparators/ppu.py
+++ b/diffoscope/comparators/ppu.py
@@ -21,16 +21,18 @@
import os
import re
+import logging
import subprocess
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.profiling import profile
from diffoscope.difference import Difference
from .utils.file import File
from .utils.command import Command
+logger = logging.getLogger(__name__)
+
class Ppudump(Command):
@tool_required('ppudump')
diff --git a/diffoscope/comparators/ps.py b/diffoscope/comparators/ps.py
index 43a1df6..ec9506e 100644
--- a/diffoscope/comparators/ps.py
+++ b/diffoscope/comparators/ps.py
@@ -18,15 +18,17 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
+import logging
from diffoscope.exc import RequiredToolNotFound
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .text import TextFile
from .utils.command import Command
+logger = logging.getLogger(__name__)
+
class Pstotext(Command):
@tool_required('ps2ascii')
diff --git a/diffoscope/comparators/rpm.py b/diffoscope/comparators/rpm.py
index 66c8549..901578c 100644
--- a/diffoscope/comparators/rpm.py
+++ b/diffoscope/comparators/rpm.py
@@ -21,17 +21,19 @@
import io
import rpm
import os.path
+import logging
import binascii
import subprocess
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.tempfiles import get_temporary_directory
from diffoscope.difference import Difference
from .rpm_fallback import AbstractRpmFile
from .utils.archive import Archive
+logger = logging.getLogger(__name__)
+
def convert_header_field(io, header):
if isinstance(header, list):
diff --git a/diffoscope/comparators/rust.py b/diffoscope/comparators/rust.py
index 98c9613..29dab1d 100644
--- a/diffoscope/comparators/rust.py
+++ b/diffoscope/comparators/rust.py
@@ -20,10 +20,10 @@
import zlib
import os.path
+import logging
import collections
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.archive import Archive
@@ -33,6 +33,8 @@ RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET = 15
RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET = 23
ZLIB_DEFAULT_COMPRESSION = b'\x78\x9C'
+logger = logging.getLogger(__name__)
+
class RustObjectContainer(Archive):
def open_archive(self):
diff --git a/diffoscope/comparators/squashfs.py b/diffoscope/comparators/squashfs.py
index 97ff7b8..df88bc1 100644
--- a/diffoscope/comparators/squashfs.py
+++ b/diffoscope/comparators/squashfs.py
@@ -20,11 +20,11 @@
import re
import stat
+import logging
import subprocess
import collections
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import Difference
from .utils.file import File
@@ -34,6 +34,8 @@ from .directory import Directory
from .utils.archive import Archive, ArchiveMember
from .utils.command import Command
+logger = logging.getLogger(__name__)
+
class SquashfsSuperblock(Command):
@tool_required('unsquashfs')
diff --git a/diffoscope/comparators/symlink.py b/diffoscope/comparators/symlink.py
index 3486351..dee618f 100644
--- a/diffoscope/comparators/symlink.py
+++ b/diffoscope/comparators/symlink.py
@@ -18,13 +18,15 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
+import logging
-from diffoscope.logging import logger
from diffoscope.tempfiles import get_named_temporary_file
from diffoscope.difference import Difference
from .utils.file import File
+logger = logging.getLogger(__name__)
+
class Symlink(File):
@staticmethod
diff --git a/diffoscope/comparators/utils/archive.py b/diffoscope/comparators/utils/archive.py
index 142b1ad..1d71b94 100644
--- a/diffoscope/comparators/utils/archive.py
+++ b/diffoscope/comparators/utils/archive.py
@@ -18,8 +18,8 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import abc
+import logging
-from diffoscope.logging import logger
from diffoscope.profiling import profile
from diffoscope.tempfiles import get_temporary_directory
@@ -28,6 +28,8 @@ from ..missing_file import MissingFile
from .file import File
from .container import Container
+logger = logging.getLogger(__name__)
+
class Archive(Container, metaclass=abc.ABCMeta):
def __new__(cls, source, *args, **kwargs):
diff --git a/diffoscope/comparators/utils/command.py b/diffoscope/comparators/utils/command.py
index d497e22..14b9b37 100644
--- a/diffoscope/comparators/utils/command.py
+++ b/diffoscope/comparators/utils/command.py
@@ -19,10 +19,11 @@
import io
import abc
+import logging
import subprocess
import threading
-from diffoscope.logging import logger
+logger = logging.getLogger(__name__)
class Command(object, metaclass=abc.ABCMeta):
diff --git a/diffoscope/comparators/utils/compare.py b/diffoscope/comparators/utils/compare.py
index c968c4b..80053c7 100644
--- a/diffoscope/comparators/utils/compare.py
+++ b/diffoscope/comparators/utils/compare.py
@@ -20,10 +20,10 @@
import io
import os
import sys
+import logging
import binascii
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.exc import RequiredToolNotFound
from diffoscope.config import Config
from diffoscope.profiling import profile
@@ -39,6 +39,8 @@ try:
except ImportError:
tlsh = None
+logger = logging.getLogger(__name__)
+
class Xxd(Command):
@tool_required('xxd')
diff --git a/diffoscope/comparators/utils/container.py b/diffoscope/comparators/utils/container.py
index c6c673e..db56f23 100644
--- a/diffoscope/comparators/utils/container.py
+++ b/diffoscope/comparators/utils/container.py
@@ -18,11 +18,11 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import abc
+import logging
import itertools
import collections
from diffoscope.config import Config
-from diffoscope.logging import logger
from diffoscope.progress import Progress
from ..missing_file import MissingFile
@@ -32,6 +32,7 @@ from .specialize import specialize
NO_COMMENT = None
+logger = logging.getLogger(__name__)
class Container(object, metaclass=abc.ABCMeta):
diff --git a/diffoscope/comparators/utils/file.py b/diffoscope/comparators/utils/file.py
index 36fc3a5..bf634ac 100644
--- a/diffoscope/comparators/utils/file.py
+++ b/diffoscope/comparators/utils/file.py
@@ -21,11 +21,11 @@ import os
import re
import abc
import magic
+import logging
import subprocess
from diffoscope.exc import RequiredToolNotFound, OutputParsingError
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.profiling import profile
from diffoscope.difference import Difference
@@ -36,6 +36,8 @@ except ImportError:
SMALL_FILE_THRESHOLD = 65536 # 64 kiB
+logger = logging.getLogger(__name__)
+
class File(object, metaclass=abc.ABCMeta):
if hasattr(magic, 'open'): # use Magic-file-extensions from file
diff --git a/diffoscope/comparators/utils/fuzzy.py b/diffoscope/comparators/utils/fuzzy.py
index 648eae4..4d6b865 100644
--- a/diffoscope/comparators/utils/fuzzy.py
+++ b/diffoscope/comparators/utils/fuzzy.py
@@ -17,16 +17,18 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
+import logging
import operator
from diffoscope.config import Config
-from diffoscope.logging import logger
try:
import tlsh
except ImportError:
tlsh = None
+logger = logging.getLogger(__name__)
+
def perform_fuzzy_matching(members1, members2):
if tlsh == None or Config().fuzzy_threshold == 0:
diff --git a/diffoscope/comparators/utils/libarchive.py b/diffoscope/comparators/utils/libarchive.py
index bae2f71..dbe3342 100644
--- a/diffoscope/comparators/utils/libarchive.py
+++ b/diffoscope/comparators/utils/libarchive.py
@@ -21,9 +21,9 @@
import time
import os.path
import ctypes
+import logging
import libarchive
-from diffoscope.logging import logger
from diffoscope.tempfiles import get_temporary_directory
from ..device import Device
@@ -32,6 +32,8 @@ from ..directory import Directory
from .archive import Archive, ArchiveMember
+logger = logging.getLogger(__name__)
+
# Monkeypatch libarchive-c (<< 2.2)
if not hasattr(libarchive.ffi, 'entry_rdevmajor'):
diff --git a/diffoscope/comparators/utils/specialize.py b/diffoscope/comparators/utils/specialize.py
index 0e7d2d9..dd22e0b 100644
--- a/diffoscope/comparators/utils/specialize.py
+++ b/diffoscope/comparators/utils/specialize.py
@@ -17,13 +17,15 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
+import logging
import importlib
-from diffoscope.logging import logger
from diffoscope.profiling import profile
from .. import COMPARATORS
+logger = logging.getLogger(__name__)
+
def specialize(file):
for cls in FILE_CLASSES:
diff --git a/diffoscope/comparators/xz.py b/diffoscope/comparators/xz.py
index 0917a30..ff7c703 100644
--- a/diffoscope/comparators/xz.py
+++ b/diffoscope/comparators/xz.py
@@ -19,16 +19,18 @@
import re
import os.path
+import logging
import subprocess
import collections
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from .utils.file import File
from .utils.archive import Archive
from .utils.filenames import get_compressed_content_name
+logger = logging.getLogger(__name__)
+
class XzContainer(Archive):
def open_archive(self):
diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 073b2f7..2abd6ec 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -22,6 +22,7 @@ import re
import io
import signal
import hashlib
+import logging
import threading
import contextlib
import subprocess
@@ -32,9 +33,10 @@ from multiprocessing.dummy import Queue
from .exc import RequiredToolNotFound
from .tools import tool_required
from .config import Config
-from .logging import logger
from .profiling import profile
+logger = logging.getLogger(__name__)
+
class DiffParser(object):
RANGE_RE = re.compile(r'^@@\s+-(?P<start1>\d+)(,(?P<len1>\d+))?\s+\+(?P<start2>\d+)(,(?P<len2>\d+))?\s+@@$')
diff --git a/diffoscope/locale.py b/diffoscope/locale.py
index 6919f9b..ab971e7 100644
--- a/diffoscope/locale.py
+++ b/diffoscope/locale.py
@@ -19,8 +19,9 @@
import os
import time
+import logging
-from .logging import logger
+logger = logging.getLogger(__name__)
def set_locale():
diff --git a/diffoscope/logging.py b/diffoscope/logging.py
index 3ec3c01..ec09321 100644
--- a/diffoscope/logging.py
+++ b/diffoscope/logging.py
@@ -19,12 +19,16 @@
import logging
-logger = logging.getLogger("diffoscope")
-logger.setLevel(logging.WARNING)
-ch = logging.StreamHandler()
-ch.setLevel(logging.DEBUG)
-logger.addHandler(ch)
+def setup_logging(debug):
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG if debug else logging.WARNING)
-formatter = logging.Formatter('%(created).3f %(levelname).1s: %(message)s')
-ch.setFormatter(formatter)
+ ch = logging.StreamHandler()
+ ch.setLevel(logging.DEBUG)
+ logger.addHandler(ch)
+
+ formatter = logging.Formatter(
+ '%(asctime)s %(levelname).1s: %(name)s: %(message)s',
+ )
+ ch.setFormatter(formatter)
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 099f0f4..2701315 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -31,7 +31,7 @@ from .exc import RequiredToolNotFound
from .tools import tool_required, OS_NAMES, get_current_os
from .config import Config
from .locale import set_locale
-from .logging import logger
+from .logging import setup_logging
from .progress import ProgressManager, Progress
from .profiling import ProfileManager, profile
from .tempfiles import clean_all_temp_files
@@ -40,6 +40,9 @@ from .presenters.html import JQUERY_SYSTEM_LOCATIONS
from .presenters.utils import output_all
from .comparators.utils.compare import compare_root_paths
+logger = logging.getLogger(__name__)
+
+
try:
import tlsh
except ImportError:
@@ -211,6 +214,7 @@ def maybe_set_limit(config, parsed_args, key):
def run_diffoscope(parsed_args):
+ setup_logging(parsed_args.debug)
if not tlsh and Config().fuzzy_threshold != parsed_args.fuzzy_threshold:
logger.warning('Fuzzy-matching is currently disabled as the "tlsh" module is unavailable.')
maybe_set_limit(Config(), parsed_args, "max_report_size")
@@ -222,8 +226,6 @@ def run_diffoscope(parsed_args):
maybe_set_limit(Config(), parsed_args, "max_diff_input_lines")
Config().fuzzy_threshold = parsed_args.fuzzy_threshold
Config().new_file = parsed_args.new_file
- if parsed_args.debug:
- logger.setLevel(logging.DEBUG)
set_locale()
logger.debug('Starting comparison')
ProgressManager().setup(parsed_args)
diff --git a/diffoscope/presenters/html/html.py b/diffoscope/presenters/html/html.py
index 42245fe..32ace28 100644
--- a/diffoscope/presenters/html/html.py
+++ b/diffoscope/presenters/html/html.py
@@ -38,11 +38,11 @@ import sys
import html
import codecs
import hashlib
+import logging
import contextlib
from diffoscope import VERSION
from diffoscope.config import Config
-from diffoscope.logging import logger
from ..icon import FAVICON_BASE64
@@ -65,6 +65,8 @@ JQUERY_SYSTEM_LOCATIONS = (
'/usr/share/javascript/jquery/jquery.js',
)
+logger = logging.getLogger(__name__)
+
class PrintLimitReached(Exception):
pass
diff --git a/diffoscope/presenters/text.py b/diffoscope/presenters/text.py
index 3a21254..2999a59 100644
--- a/diffoscope/presenters/text.py
+++ b/diffoscope/presenters/text.py
@@ -20,11 +20,13 @@
import subprocess
import sys
+import logging
from diffoscope.tools import tool_required
-from diffoscope.logging import logger
from diffoscope.difference import color_unified_diff
+logger = logging.getLogger(__name__)
+
def print_difference(difference, print_func, color=False):
if difference.comments:
diff --git a/diffoscope/presenters/utils.py b/diffoscope/presenters/utils.py
index 9e3c394..dfbd019 100644
--- a/diffoscope/presenters/utils.py
+++ b/diffoscope/presenters/utils.py
@@ -19,14 +19,16 @@
import sys
import codecs
+import logging
import contextlib
-from ..logging import logger
from ..profiling import profile
from .text import output_text
from .html import output_html, output_html_directory
+logger = logging.getLogger(__name__)
+
def output_all(difference, parsed_args, has_differences):
"""
diff --git a/diffoscope/tempfiles.py b/diffoscope/tempfiles.py
index d0ddff5..1fe2e6b 100644
--- a/diffoscope/tempfiles.py
+++ b/diffoscope/tempfiles.py
@@ -18,12 +18,13 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
+import logging
import tempfile
-from .logging import logger
-
_DIRS, _FILES = [], []
+logger = logging.getLogger(__name__)
+
def get_named_temporary_file(*args, **kwargs):
kwargs['suffix'] = kwargs.pop('suffix', '_diffoscope')
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list