removed the usage of logzero, added a formal logging configuration file using json
This commit is contained in:
parent
59e6b6630a
commit
742ad0e3a2
3 changed files with 33 additions and 8 deletions
|
@ -1,9 +1,14 @@
|
||||||
import logzero
|
import json
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import os
|
||||||
|
|
||||||
# configure custom format with function name
|
from core import constants
|
||||||
_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)
|
|
||||||
|
|
||||||
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
20
daemon/data/logging.conf
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,6 @@ setup(
|
||||||
],
|
],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"enum34",
|
"enum34",
|
||||||
#"logzero",
|
|
||||||
],
|
],
|
||||||
tests_require=[
|
tests_require=[
|
||||||
"pytest",
|
"pytest",
|
||||||
|
@ -34,6 +33,7 @@ setup(
|
||||||
("/etc/core", [
|
("/etc/core", [
|
||||||
"data/core.conf",
|
"data/core.conf",
|
||||||
"data/xen.conf",
|
"data/xen.conf",
|
||||||
|
"data/logging.conf",
|
||||||
]),
|
]),
|
||||||
("/etc/init.d", [
|
("/etc/init.d", [
|
||||||
"../scripts/core-daemon",
|
"../scripts/core-daemon",
|
||||||
|
|
Loading…
Add table
Reference in a new issue