Move the logging settings to the module pool initialization

parent 1c2c2d1b
......@@ -26,11 +26,8 @@ from __future__ import print_function
from __future__ import absolute_import
import os
import argparse
import logging
import sys
from .util import path as path_mod
from .util.termcolor import colored
from .manifest_parser import ManifestParser
from .module_pool import ModulePool
from . import fetch as fetch_mod
......@@ -55,27 +52,6 @@ def main():
#
options = _get_options(sys, parser)
# Here we set the log level (A.K.A.) debug verbosity)
numeric_level = getattr(logging, options.log.upper(), None)
if not isinstance(numeric_level, int):
sys.exit('Invalid log level: %s' % options.log)
if not path_mod.check_windows():
logging.basicConfig(
format=colored(
"%(levelname)s",
"yellow") + colored(
"\t%(filename)s:%(lineno)d: %(funcName)s()\t",
"blue") + "%(message)s",
level=numeric_level)
else:
logging.basicConfig(
format="%(levelname)s" +
"\t%(filename)s:%(lineno)d: %(funcName)s()\t" +
"%(message)s",
level=numeric_level)
logging.debug(str(options))
# Create a ModulePool object, this will become our workspace
modules_pool = ModulePool(options)
......
......@@ -30,9 +30,33 @@ from subprocess import PIPE, Popen
import sys
from hdlmake.util import path as path_mod
from hdlmake.util.termcolor import colored
from hdlmake import new_dep_solver as dep_solver
def set_logging_level(options):
"""Set the log level and config (A.K.A. log verbosity)"""
numeric_level = getattr(logging, options.log.upper(), None)
if not isinstance(numeric_level, int):
sys.exit('Invalid log level: %s' % options.log)
if not path_mod.check_windows():
logging.basicConfig(
format=colored(
"%(levelname)s",
"yellow") + colored(
"\t%(filename)s:%(lineno)d: %(funcName)s()\t",
"blue") + "%(message)s",
level=numeric_level)
else:
logging.basicConfig(
format="%(levelname)s" +
"\t%(filename)s:%(lineno)d: %(funcName)s()\t" +
"%(message)s",
level=numeric_level)
logging.debug(str(options))
class Action(list):
"""This is the base class providing the common Action methods"""
......@@ -41,6 +65,7 @@ class Action(list):
self.top_module = None
self._deps_solved = False
self.options = options
set_logging_level(options)
super(Action, self).__init__()
def new_module(self, parent, url, source, fetchto):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment