|
|
0fcfce |
From 9f9bfdfcb576846436f97275d6ee82004ceb4cb9 Mon Sep 17 00:00:00 2001
|
|
|
0fcfce |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
0fcfce |
Date: Thu, 4 Jun 2020 16:02:58 +0200
|
|
|
0fcfce |
Subject: [PATCH 1/3] Add logfilelevel configuration (RhBug:1802074)
|
|
|
0fcfce |
|
|
|
0fcfce |
https://bugzilla.redhat.com/show_bug.cgi?id=1802074
|
|
|
0fcfce |
---
|
|
|
0fcfce |
dnf.spec | 2 +-
|
|
|
0fcfce |
dnf/logging.py | 17 +++++++++++------
|
|
|
0fcfce |
doc/conf_ref.rst | 6 ++++++
|
|
|
0fcfce |
3 files changed, 18 insertions(+), 7 deletions(-)
|
|
|
0fcfce |
|
|
|
0fcfce |
diff --git a/dnf.spec b/dnf.spec
|
|
|
0fcfce |
index 1423c6d5b5..27bae7aaa7 100644
|
|
|
0fcfce |
--- a/dnf.spec
|
|
|
0fcfce |
+++ b/dnf.spec
|
|
|
0fcfce |
@@ -1,5 +1,5 @@
|
|
|
0fcfce |
# default dependencies
|
|
|
0fcfce |
-%global hawkey_version 0.48.0
|
|
|
0fcfce |
+%global hawkey_version 0.50.0
|
|
|
0fcfce |
%global libcomps_version 0.1.8
|
|
|
0fcfce |
%global libmodulemd_version 1.4.0
|
|
|
0fcfce |
%global rpm_version 4.14.0
|
|
|
0fcfce |
diff --git a/dnf/logging.py b/dnf/logging.py
|
|
|
0fcfce |
index bd660470a3..c578575e1c 100644
|
|
|
0fcfce |
--- a/dnf/logging.py
|
|
|
0fcfce |
+++ b/dnf/logging.py
|
|
|
0fcfce |
@@ -70,11 +70,14 @@ def filter(self, record):
|
|
|
0fcfce |
4 : logging.DEBUG,
|
|
|
0fcfce |
5 : logging.DEBUG,
|
|
|
0fcfce |
6 : logging.DEBUG, # verbose value
|
|
|
0fcfce |
+ 7 : DDEBUG,
|
|
|
0fcfce |
+ 8 : SUBDEBUG,
|
|
|
0fcfce |
+ 9 : TRACE,
|
|
|
0fcfce |
}
|
|
|
0fcfce |
|
|
|
0fcfce |
def _cfg_verbose_val2level(cfg_errval):
|
|
|
0fcfce |
assert 0 <= cfg_errval <= 10
|
|
|
0fcfce |
- return _VERBOSE_VAL_MAPPING.get(cfg_errval, DDEBUG)
|
|
|
0fcfce |
+ return _VERBOSE_VAL_MAPPING.get(cfg_errval, TRACE)
|
|
|
0fcfce |
|
|
|
0fcfce |
|
|
|
0fcfce |
# Both the DNF default and the verbose default are WARNING. Note that ERROR has
|
|
|
0fcfce |
@@ -157,13 +160,14 @@ def _presetup(self):
|
|
|
0fcfce |
self.stderr_handler = stderr
|
|
|
0fcfce |
|
|
|
0fcfce |
@only_once
|
|
|
0fcfce |
- def _setup_file_loggers(self, verbose_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
+ def _setup_file_loggers(self, logfile_level, verbose_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
logger_dnf = logging.getLogger("dnf")
|
|
|
0fcfce |
logger_dnf.setLevel(TRACE)
|
|
|
0fcfce |
|
|
|
0fcfce |
# setup file logger
|
|
|
0fcfce |
logfile = os.path.join(logdir, dnf.const.LOG)
|
|
|
0fcfce |
handler = _create_filehandler(logfile, log_size, log_rotate)
|
|
|
0fcfce |
+ handler.setLevel(logfile_level)
|
|
|
0fcfce |
logger_dnf.addHandler(handler)
|
|
|
0fcfce |
# put the marker in the file now:
|
|
|
0fcfce |
_paint_mark(logger_dnf)
|
|
|
0fcfce |
@@ -185,14 +189,14 @@ def _setup_file_loggers(self, verbose_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
_paint_mark(logger_rpm)
|
|
|
0fcfce |
|
|
|
0fcfce |
@only_once
|
|
|
0fcfce |
- def _setup(self, verbose_level, error_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
+ def _setup(self, verbose_level, error_level, logfile_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
self._presetup()
|
|
|
0fcfce |
|
|
|
0fcfce |
# temporarily turn off stdout/stderr handlers:
|
|
|
0fcfce |
self.stdout_handler.setLevel(SUPERCRITICAL)
|
|
|
0fcfce |
self.stderr_handler.setLevel(SUPERCRITICAL)
|
|
|
0fcfce |
|
|
|
0fcfce |
- self._setup_file_loggers(verbose_level, logdir, log_size, log_rotate)
|
|
|
0fcfce |
+ self._setup_file_loggers(logfile_level, verbose_level, logdir, log_size, log_rotate)
|
|
|
0fcfce |
|
|
|
0fcfce |
logger_warnings = logging.getLogger("py.warnings")
|
|
|
0fcfce |
logger_warnings.addHandler(self.stderr_handler)
|
|
|
0fcfce |
@@ -209,13 +213,14 @@ def _setup(self, verbose_level, error_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
def _setup_from_dnf_conf(self, conf, file_loggers_only=False):
|
|
|
0fcfce |
verbose_level_r = _cfg_verbose_val2level(conf.debuglevel)
|
|
|
0fcfce |
error_level_r = _cfg_err_val2level(conf.errorlevel)
|
|
|
0fcfce |
+ logfile_level_r = _cfg_verbose_val2level(conf.logfilelevel)
|
|
|
0fcfce |
logdir = conf.logdir
|
|
|
0fcfce |
log_size = conf.log_size
|
|
|
0fcfce |
log_rotate = conf.log_rotate
|
|
|
0fcfce |
if file_loggers_only:
|
|
|
0fcfce |
- return self._setup_file_loggers(verbose_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
+ return self._setup_file_loggers(logfile_level_r, verbose_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
else:
|
|
|
0fcfce |
- return self._setup(verbose_level_r, error_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
+ return self._setup(verbose_level_r, error_level_r, logfile_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
|
|
|
0fcfce |
|
|
|
0fcfce |
class Timer(object):
|
|
|
0fcfce |
diff --git a/doc/conf_ref.rst b/doc/conf_ref.rst
|
|
|
0fcfce |
index cf442770c9..fed6efcec7 100644
|
|
|
0fcfce |
--- a/doc/conf_ref.rst
|
|
|
0fcfce |
+++ b/doc/conf_ref.rst
|
|
|
0fcfce |
@@ -268,6 +268,12 @@ configuration file by your distribution to override the DNF defaults.
|
|
|
0fcfce |
|
|
|
0fcfce |
Directory where the log files will be stored. Default is ``/var/log``.
|
|
|
0fcfce |
|
|
|
0fcfce |
+``logfilelevel``
|
|
|
0fcfce |
+ :ref:`integer <integer-label>`
|
|
|
0fcfce |
+
|
|
|
0fcfce |
+ Log file messages output level, in the range 0 to 10. The higher the number the
|
|
|
0fcfce |
+ more debug output is put to logs. Default is 9.
|
|
|
0fcfce |
+
|
|
|
0fcfce |
.. _log_rotate-label:
|
|
|
0fcfce |
|
|
|
0fcfce |
``log_rotate``
|
|
|
0fcfce |
|
|
|
0fcfce |
From 1233d7da657ffbd03f9ffc274b648da0bb2898bf Mon Sep 17 00:00:00 2001
|
|
|
0fcfce |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
0fcfce |
Date: Fri, 5 Jun 2020 09:21:15 +0200
|
|
|
0fcfce |
Subject: [PATCH 2/3] Update unit logging test to reflect logfilelevel addition
|
|
|
0fcfce |
|
|
|
0fcfce |
---
|
|
|
0fcfce |
tests/test_logging.py | 16 +++++++++-------
|
|
|
0fcfce |
1 file changed, 9 insertions(+), 7 deletions(-)
|
|
|
0fcfce |
|
|
|
0fcfce |
diff --git a/tests/test_logging.py b/tests/test_logging.py
|
|
|
0fcfce |
index a7fee3e67c..80e219d882 100644
|
|
|
0fcfce |
--- a/tests/test_logging.py
|
|
|
0fcfce |
+++ b/tests/test_logging.py
|
|
|
0fcfce |
@@ -88,7 +88,7 @@ def test_setup(self):
|
|
|
0fcfce |
logger = logging.getLogger("dnf")
|
|
|
0fcfce |
with tests.support.patch_std_streams() as (stdout, stderr):
|
|
|
0fcfce |
self.logging._setup(
|
|
|
0fcfce |
- logging.INFO, logging.ERROR, self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
+ logging.INFO, logging.ERROR, dnf.logging.TRACE, self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
self._bench(logger)
|
|
|
0fcfce |
self.assertEqual("i\n", stdout.getvalue())
|
|
|
0fcfce |
self.assertEqual("e\n", stderr.getvalue())
|
|
|
0fcfce |
@@ -97,7 +97,7 @@ def test_setup_verbose(self):
|
|
|
0fcfce |
logger = logging.getLogger("dnf")
|
|
|
0fcfce |
with tests.support.patch_std_streams() as (stdout, stderr):
|
|
|
0fcfce |
self.logging._setup(
|
|
|
0fcfce |
- logging.DEBUG, logging.WARNING, self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
+ logging.DEBUG, logging.WARNING, dnf.logging.TRACE, self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
self._bench(logger)
|
|
|
0fcfce |
self.assertEqual("d\ni\n", stdout.getvalue())
|
|
|
0fcfce |
self.assertEqual("w\ne\n", stderr.getvalue())
|
|
|
0fcfce |
@@ -105,20 +105,22 @@ def test_setup_verbose(self):
|
|
|
0fcfce |
@mock.patch('dnf.logging.Logging._setup')
|
|
|
0fcfce |
def test_setup_from_dnf_conf(self, setup_m):
|
|
|
0fcfce |
conf = mock.Mock(
|
|
|
0fcfce |
- debuglevel=2, errorlevel=3, logdir=self.logdir,
|
|
|
0fcfce |
+ debuglevel=2, errorlevel=3, logfilelevel=2, logdir=self.logdir,
|
|
|
0fcfce |
log_size=self.log_size, log_rotate=self.log_rotate)
|
|
|
0fcfce |
self.logging._setup_from_dnf_conf(conf)
|
|
|
0fcfce |
self.assertEqual(setup_m.call_args, mock.call(dnf.logging.INFO,
|
|
|
0fcfce |
dnf.logging.WARNING,
|
|
|
0fcfce |
+ dnf.logging.INFO,
|
|
|
0fcfce |
self.logdir,
|
|
|
0fcfce |
self.log_size,
|
|
|
0fcfce |
self.log_rotate))
|
|
|
0fcfce |
conf = mock.Mock(
|
|
|
0fcfce |
- debuglevel=6, errorlevel=6, logdir=self.logdir,
|
|
|
0fcfce |
+ debuglevel=6, errorlevel=6, logfilelevel=6, logdir=self.logdir,
|
|
|
0fcfce |
log_size=self.log_size, log_rotate=self.log_rotate)
|
|
|
0fcfce |
self.logging._setup_from_dnf_conf(conf)
|
|
|
0fcfce |
self.assertEqual(setup_m.call_args, mock.call(dnf.logging.DEBUG,
|
|
|
0fcfce |
dnf.logging.WARNING,
|
|
|
0fcfce |
+ dnf.logging.DEBUG,
|
|
|
0fcfce |
self.logdir,
|
|
|
0fcfce |
self.log_size,
|
|
|
0fcfce |
self.log_rotate))
|
|
|
0fcfce |
@@ -126,7 +128,7 @@ def test_setup_from_dnf_conf(self, setup_m):
|
|
|
0fcfce |
def test_file_logging(self):
|
|
|
0fcfce |
# log nothing to the console:
|
|
|
0fcfce |
self.logging._setup(
|
|
|
0fcfce |
- dnf.logging.SUPERCRITICAL, dnf.logging.SUPERCRITICAL,
|
|
|
0fcfce |
+ dnf.logging.SUPERCRITICAL, dnf.logging.SUPERCRITICAL, dnf.logging.TRACE,
|
|
|
0fcfce |
self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
logger = logging.getLogger("dnf")
|
|
|
0fcfce |
with tests.support.patch_std_streams() as (stdout, stderr):
|
|
|
0fcfce |
@@ -145,7 +147,7 @@ def test_file_logging(self):
|
|
|
0fcfce |
def test_rpm_logging(self):
|
|
|
0fcfce |
# log everything to the console:
|
|
|
0fcfce |
self.logging._setup(
|
|
|
0fcfce |
- dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG,
|
|
|
0fcfce |
+ dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG, dnf.logging.TRACE,
|
|
|
0fcfce |
self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
logger = logging.getLogger("dnf.rpm")
|
|
|
0fcfce |
with tests.support.patch_std_streams() as (stdout, stderr):
|
|
|
0fcfce |
@@ -167,7 +169,7 @@ def test_setup_only_once(self):
|
|
|
0fcfce |
logger = logging.getLogger("dnf")
|
|
|
0fcfce |
self.assertLength(logger.handlers, 0)
|
|
|
0fcfce |
self.logging._setup(
|
|
|
0fcfce |
- dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG,
|
|
|
0fcfce |
+ dnf.logging.SUBDEBUG, dnf.logging.SUBDEBUG, dnf.logging.TRACE,
|
|
|
0fcfce |
self.logdir, self.log_size, self.log_rotate)
|
|
|
0fcfce |
cnt = len(logger.handlers)
|
|
|
0fcfce |
self.assertGreater(cnt, 0)
|
|
|
0fcfce |
|
|
|
0fcfce |
From 8a57da7229c67315d113b3c61cf981e1a7d81189 Mon Sep 17 00:00:00 2001
|
|
|
0fcfce |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
0fcfce |
Date: Thu, 25 Jun 2020 14:03:02 +0200
|
|
|
0fcfce |
Subject: [PATCH 3/3] Control hawkey and librepo log verbosity with
|
|
|
0fcfce |
logfilelevel
|
|
|
0fcfce |
|
|
|
0fcfce |
= changelog =
|
|
|
0fcfce |
msg: New config option 'logfilelevel' now controls logging to dnf.log, dnf.librepo.log and hawkey.log
|
|
|
0fcfce |
type: enhancement
|
|
|
0fcfce |
resolves: 1802074
|
|
|
0fcfce |
---
|
|
|
0fcfce |
dnf/logging.py | 11 +++++++----
|
|
|
0fcfce |
dnf/sack.py | 2 +-
|
|
|
0fcfce |
doc/conf_ref.rst | 3 +++
|
|
|
0fcfce |
3 files changed, 11 insertions(+), 5 deletions(-)
|
|
|
0fcfce |
|
|
|
0fcfce |
diff --git a/dnf/logging.py b/dnf/logging.py
|
|
|
0fcfce |
index c578575e1c..b5196988f7 100644
|
|
|
0fcfce |
--- a/dnf/logging.py
|
|
|
0fcfce |
+++ b/dnf/logging.py
|
|
|
0fcfce |
@@ -43,6 +43,7 @@
|
|
|
0fcfce |
DDEBUG = 8 # used by anaconda (pyanaconda/payload/dnfpayload.py)
|
|
|
0fcfce |
SUBDEBUG = 6
|
|
|
0fcfce |
TRACE = 4
|
|
|
0fcfce |
+ALL = 2
|
|
|
0fcfce |
|
|
|
0fcfce |
def only_once(func):
|
|
|
0fcfce |
"""Method decorator turning the method into noop on second or later calls."""
|
|
|
0fcfce |
@@ -73,6 +74,7 @@ def filter(self, record):
|
|
|
0fcfce |
7 : DDEBUG,
|
|
|
0fcfce |
8 : SUBDEBUG,
|
|
|
0fcfce |
9 : TRACE,
|
|
|
0fcfce |
+ 10: ALL, # more verbous librepo and hawkey
|
|
|
0fcfce |
}
|
|
|
0fcfce |
|
|
|
0fcfce |
def _cfg_verbose_val2level(cfg_errval):
|
|
|
0fcfce |
@@ -138,6 +140,7 @@ def __init__(self):
|
|
|
0fcfce |
logging.addLevelName(DDEBUG, "DDEBUG")
|
|
|
0fcfce |
logging.addLevelName(SUBDEBUG, "SUBDEBUG")
|
|
|
0fcfce |
logging.addLevelName(TRACE, "TRACE")
|
|
|
0fcfce |
+ logging.addLevelName(ALL, "ALL")
|
|
|
0fcfce |
logging.captureWarnings(True)
|
|
|
0fcfce |
logging.raiseExceptions = False
|
|
|
0fcfce |
|
|
|
0fcfce |
@@ -160,7 +163,7 @@ def _presetup(self):
|
|
|
0fcfce |
self.stderr_handler = stderr
|
|
|
0fcfce |
|
|
|
0fcfce |
@only_once
|
|
|
0fcfce |
- def _setup_file_loggers(self, logfile_level, verbose_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
+ def _setup_file_loggers(self, logfile_level, logdir, log_size, log_rotate):
|
|
|
0fcfce |
logger_dnf = logging.getLogger("dnf")
|
|
|
0fcfce |
logger_dnf.setLevel(TRACE)
|
|
|
0fcfce |
|
|
|
0fcfce |
@@ -177,7 +180,7 @@ def _setup_file_loggers(self, logfile_level, verbose_level, logdir, log_size, lo
|
|
|
0fcfce |
logger_warnings.addHandler(handler)
|
|
|
0fcfce |
|
|
|
0fcfce |
lr_logfile = os.path.join(logdir, dnf.const.LOG_LIBREPO)
|
|
|
0fcfce |
- libdnf.repo.LibrepoLog.addHandler(lr_logfile, verbose_level <= DEBUG)
|
|
|
0fcfce |
+ libdnf.repo.LibrepoLog.addHandler(lr_logfile, logfile_level <= ALL)
|
|
|
0fcfce |
|
|
|
0fcfce |
# setup RPM callbacks logger
|
|
|
0fcfce |
logger_rpm = logging.getLogger("dnf.rpm")
|
|
|
0fcfce |
@@ -196,7 +199,7 @@ def _setup(self, verbose_level, error_level, logfile_level, logdir, log_size, lo
|
|
|
0fcfce |
self.stdout_handler.setLevel(SUPERCRITICAL)
|
|
|
0fcfce |
self.stderr_handler.setLevel(SUPERCRITICAL)
|
|
|
0fcfce |
|
|
|
0fcfce |
- self._setup_file_loggers(logfile_level, verbose_level, logdir, log_size, log_rotate)
|
|
|
0fcfce |
+ self._setup_file_loggers(logfile_level, logdir, log_size, log_rotate)
|
|
|
0fcfce |
|
|
|
0fcfce |
logger_warnings = logging.getLogger("py.warnings")
|
|
|
0fcfce |
logger_warnings.addHandler(self.stderr_handler)
|
|
|
0fcfce |
@@ -218,7 +221,7 @@ def _setup_from_dnf_conf(self, conf, file_loggers_only=False):
|
|
|
0fcfce |
log_size = conf.log_size
|
|
|
0fcfce |
log_rotate = conf.log_rotate
|
|
|
0fcfce |
if file_loggers_only:
|
|
|
0fcfce |
- return self._setup_file_loggers(logfile_level_r, verbose_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
+ return self._setup_file_loggers(logfile_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
else:
|
|
|
0fcfce |
return self._setup(verbose_level_r, error_level_r, logfile_level_r, logdir, log_size, log_rotate)
|
|
|
0fcfce |
|
|
|
0fcfce |
diff --git a/dnf/sack.py b/dnf/sack.py
|
|
|
0fcfce |
index fb8c70712f..3c6bc3bbe0 100644
|
|
|
0fcfce |
--- a/dnf/sack.py
|
|
|
0fcfce |
+++ b/dnf/sack.py
|
|
|
0fcfce |
@@ -53,7 +53,7 @@ def _build_sack(base):
|
|
|
0fcfce |
arch=base.conf.substitutions["arch"],
|
|
|
0fcfce |
cachedir=cachedir, rootdir=base.conf.installroot,
|
|
|
0fcfce |
logfile=os.path.join(base.conf.logdir, dnf.const.LOG_HAWKEY),
|
|
|
0fcfce |
- logdebug=base.conf.debuglevel > 2)
|
|
|
0fcfce |
+ logdebug=base.conf.logfilelevel > 9)
|
|
|
0fcfce |
|
|
|
0fcfce |
|
|
|
0fcfce |
def _rpmdb_sack(base):
|
|
|
0fcfce |
diff --git a/doc/conf_ref.rst b/doc/conf_ref.rst
|
|
|
0fcfce |
index fed6efcec7..fdb44a657d 100644
|
|
|
0fcfce |
--- a/doc/conf_ref.rst
|
|
|
0fcfce |
+++ b/doc/conf_ref.rst
|
|
|
0fcfce |
@@ -274,6 +274,9 @@ configuration file by your distribution to override the DNF defaults.
|
|
|
0fcfce |
Log file messages output level, in the range 0 to 10. The higher the number the
|
|
|
0fcfce |
more debug output is put to logs. Default is 9.
|
|
|
0fcfce |
|
|
|
0fcfce |
+ This option controls dnf.log, dnf.librepo.log and hawkey.log. Although dnf.librepo.log
|
|
|
0fcfce |
+ and hawkey.log are affected only by setting the logfilelevel to 10.
|
|
|
0fcfce |
+
|
|
|
0fcfce |
.. _log_rotate-label:
|
|
|
0fcfce |
|
|
|
0fcfce |
``log_rotate``
|