updates to python based logging to use module named loggers, updated logging config file to align with these changes

This commit is contained in:
Blake Harnden 2021-04-21 21:09:35 -07:00
parent 55d5bb3859
commit 69652ac577
63 changed files with 717 additions and 606 deletions

View file

@ -14,6 +14,7 @@ from core.config import Configuration
from core.errors import CoreCommandError, CoreError
from core.nodes.base import CoreNode
logger = logging.getLogger(__name__)
TEMPLATES_DIR: str = "templates"
@ -133,7 +134,7 @@ class ConfigService(abc.ABC):
:return: nothing
:raises ConfigServiceBootError: when there is an error starting service
"""
logging.info("node(%s) service(%s) starting...", self.node.name, self.name)
logger.info("node(%s) service(%s) starting...", self.node.name, self.name)
self.create_dirs()
self.create_files()
wait = self.validation_mode == ConfigServiceMode.BLOCKING
@ -154,7 +155,7 @@ class ConfigService(abc.ABC):
try:
self.node.cmd(cmd)
except CoreCommandError:
logging.exception(
logger.exception(
f"node({self.node.name}) service({self.name}) "
f"failed shutdown: {cmd}"
)
@ -250,7 +251,7 @@ class ConfigService(abc.ABC):
else:
text = self.get_text_template(name)
rendered = self.render_text(text, data)
logging.debug(
logger.debug(
"node(%s) service(%s) template(%s): \n%s",
self.node.name,
self.name,
@ -301,7 +302,7 @@ class ConfigService(abc.ABC):
del cmds[index]
index += 1
except CoreCommandError:
logging.debug(
logger.debug(
f"node({self.node.name}) service({self.name}) "
f"validate command failed: {cmd}"
)

View file

@ -1,6 +1,8 @@
import logging
from typing import TYPE_CHECKING, Dict, List, Set
logger = logging.getLogger(__name__)
if TYPE_CHECKING:
from core.configservice.base import ConfigService
@ -41,7 +43,7 @@ class ConfigServiceDependencies:
for name in self.node_services:
service = self.node_services[name]
if service.name in self.started:
logging.debug(
logger.debug(
"skipping service that will already be started: %s", service.name
)
continue
@ -75,7 +77,7 @@ class ConfigServiceDependencies:
:param service: service to check dependencies for
:return: list of config services to start in order
"""
logging.debug("starting service dependency check: %s", service.name)
logger.debug("starting service dependency check: %s", service.name)
self._reset()
return self._visit(service)
@ -86,7 +88,7 @@ class ConfigServiceDependencies:
:param current_service: service being visited
:return: list of dependent services for a visited service
"""
logging.debug("visiting service(%s): %s", current_service.name, self.path)
logger.debug("visiting service(%s): %s", current_service.name, self.path)
self.visited.add(current_service.name)
self.visiting.add(current_service.name)
@ -109,7 +111,7 @@ class ConfigServiceDependencies:
self._visit(service)
# add service when bottom is found
logging.debug("adding service to startup path: %s", current_service.name)
logger.debug("adding service to startup path: %s", current_service.name)
self.started.add(current_service.name)
self.path.append(current_service)
self.visiting.remove(current_service.name)

View file

@ -7,6 +7,8 @@ from core import utils
from core.configservice.base import ConfigService
from core.errors import CoreError
logger = logging.getLogger(__name__)
class ConfigServiceManager:
"""
@ -41,7 +43,7 @@ class ConfigServiceManager:
:raises CoreError: when service is a duplicate or has unmet executables
"""
name = service.name
logging.debug(
logger.debug(
"loading service: class(%s) name(%s)", service.__class__.__name__, name
)
@ -71,12 +73,12 @@ class ConfigServiceManager:
subdirs.append(path)
service_errors = []
for subdir in subdirs:
logging.debug("loading config services from: %s", subdir)
logger.debug("loading config services from: %s", subdir)
services = utils.load_classes(subdir, ConfigService)
for service in services:
try:
self.add(service)
except CoreError as e:
service_errors.append(service.name)
logging.debug("not loading service(%s): %s", service.name, e)
logger.debug("not loading service(%s): %s", service.name, e)
return service_errors