removed the usage of logzero, added a formal logging configuration file using json

This commit is contained in:
Blake J. Harnden 2018-01-03 10:53:34 -08:00
parent 59e6b6630a
commit 742ad0e3a2
3 changed files with 33 additions and 8 deletions

View file

@ -1,9 +1,14 @@
import logzero
import json
import logging
import logging.config
import os
# configure custom format with function name
_format_template = "%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(funcName)s:" \
"%(lineno)d]%(end_color)s %(message)s"
_formatter = logzero.LogFormatter(fmt=_format_template)
logzero.formatter(_formatter)
from core import constants
logger = logzero.logger
log_config_path = os.path.join(constants.CORE_CONF_DIR, "logging.conf")
with open(log_config_path, "r") as log_config_file:
log_config = json.load(log_config_file)
logging.config.dictConfig(log_config)
#logging.basicConfig(format="%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s", level=logging.DEBUG)
logger = logging.getLogger()

20
daemon/data/logging.conf Normal file
View file

@ -0,0 +1,20 @@
{
"version": 1,
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "default",
"level": "DEBUG",
"stream": "ext://sys.stdout"
}
},
"formatters": {
"default": {
"format": "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"
}
},
"root": {
"level": "DEBUG",
"handlers": ["console"]
}
}

View file

@ -22,7 +22,6 @@ setup(
],
install_requires=[
"enum34",
#"logzero",
],
tests_require=[
"pytest",
@ -34,6 +33,7 @@ setup(
("/etc/core", [
"data/core.conf",
"data/xen.conf",
"data/logging.conf",
]),
("/etc/init.d", [
"../scripts/core-daemon",