app and default logging joined except of fmt
This commit is contained in:
parent
c9642f1a2b
commit
5995368f07
29
__init__.py
29
__init__.py
@ -43,7 +43,7 @@ except ImportError:
|
|||||||
try:
|
try:
|
||||||
from config import LOG_LEVEL
|
from config import LOG_LEVEL
|
||||||
except ImportError:
|
except ImportError:
|
||||||
LOG_LEVEL = logging.DEBUG
|
LOG_LEVEL = logging.WARNING
|
||||||
try:
|
try:
|
||||||
from config import LOG_HOSTNAME
|
from config import LOG_HOSTNAME
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -215,22 +215,6 @@ def add_handler_socket(logger: logging.Logger, level: int = logging.DEBUG, host:
|
|||||||
return handler
|
return handler
|
||||||
|
|
||||||
|
|
||||||
def app_logging_config():
|
|
||||||
"""You are able to configure logging by a config file including these line:
|
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
#
|
|
||||||
# Logging
|
|
||||||
#
|
|
||||||
APP_NAME = "<YOUR_APP_NAME>"
|
|
||||||
LOG_HOSTNAME = "loggy" # When DEBUG is True
|
|
||||||
"""
|
|
||||||
logger = logging.getLogger(ROOT_LOGGER_NAME)
|
|
||||||
if DEBUG:
|
|
||||||
add_handler_socket(logger, host=LOG_HOSTNAME)
|
|
||||||
return logger.getChild('main')
|
|
||||||
|
|
||||||
|
|
||||||
def default_logging_config(fmt=JOURNAL_FMT):
|
def default_logging_config(fmt=JOURNAL_FMT):
|
||||||
"""You are able to configure logging by a config file including these line:
|
"""You are able to configure logging by a config file including these line:
|
||||||
|
|
||||||
@ -248,7 +232,16 @@ def default_logging_config(fmt=JOURNAL_FMT):
|
|||||||
logger = logging.getLogger(ROOT_LOGGER_NAME)
|
logger = logging.getLogger(ROOT_LOGGER_NAME)
|
||||||
|
|
||||||
add_handler_stdout(logger, LOG_LEVEL, fmt=fmt)
|
add_handler_stdout(logger, LOG_LEVEL, fmt=fmt)
|
||||||
return app_logging_config()
|
if DEBUG:
|
||||||
|
add_handler_socket(logger, host=LOG_HOSTNAME)
|
||||||
|
return logger.getChild('main')
|
||||||
|
|
||||||
|
|
||||||
|
def app_logging_config():
|
||||||
|
"""
|
||||||
|
For details see comment in default_logging_config.
|
||||||
|
"""
|
||||||
|
return default_logging_config(LONG_FMT)
|
||||||
|
|
||||||
|
|
||||||
class testSession(dict):
|
class testSession(dict):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user