ostree: Silence logger in tests

Instead of creating and configuring the logger at module import time, we
can only get the logger if it's actually needed and configure it from
the main script.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-02-22 10:09:39 +01:00
parent 3162fea60d
commit 9e020c2782
2 changed files with 8 additions and 9 deletions

View File

@ -15,6 +15,7 @@
import argparse import argparse
import logging
from .tree import Tree from .tree import Tree
from .installer import Installer from .installer import Installer
@ -79,6 +80,9 @@ def main(args=None):
help='JSON file contains extra configurations') help='JSON file contains extra configurations')
args = parser.parse_args(args) args = parser.parse_args(args)
logging.basicConfig(format="%(message)s", level=logging.DEBUG)
_class = args._class() _class = args._class()
_class.set_args(args) _class.set_args(args)
func = getattr(_class, args.func) func = getattr(_class, args.func)

View File

@ -23,13 +23,6 @@ import rpmUtils.arch
from pungi.util import makedirs from pungi.util import makedirs
ostree_utils_logger = logging.getLogger("ostree.utils")
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(message)s"))
handler.setLevel(logging.DEBUG)
ostree_utils_logger.addHandler(handler)
def make_log_file(log_dir, filename): def make_log_file(log_dir, filename):
"""Return path to log file with given name, if log_dir is set.""" """Return path to log file with given name, if log_dir is set."""
if not log_dir: if not log_dir:
@ -38,11 +31,12 @@ def make_log_file(log_dir, filename):
return os.path.join(log_dir, '%s.log' % filename) return os.path.join(log_dir, '%s.log' % filename)
def get_ref_from_treefile(treefile, arch=None, logger=ostree_utils_logger): def get_ref_from_treefile(treefile, arch=None, logger=None):
""" """
Return ref name by parsing the tree config file. Replacing ${basearch} with Return ref name by parsing the tree config file. Replacing ${basearch} with
the basearch of the architecture we are running on or of the passed in arch. the basearch of the architecture we are running on or of the passed in arch.
""" """
logger = logger or logging.getLogger(__name__)
ref = None ref = None
if os.path.isfile(treefile): if os.path.isfile(treefile):
with open(treefile, 'r') as f: with open(treefile, 'r') as f:
@ -60,8 +54,9 @@ def get_ref_from_treefile(treefile, arch=None, logger=ostree_utils_logger):
return ref return ref
def get_commitid_from_commitid_file(commitid_file, logger=ostree_utils_logger): def get_commitid_from_commitid_file(commitid_file, logger=None):
"""Return commit id which is read from the commitid file""" """Return commit id which is read from the commitid file"""
logger = logger or logging.getLogger(__name__)
commitid = None commitid = None
if os.path.isfile(commitid_file): if os.path.isfile(commitid_file):
with open(commitid_file, 'r') as f: with open(commitid_file, 'r') as f: