blob: 5e52a9f66a37cae67311666560e0dd76bdc206f7 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
"""Setup loggers"""
import sys
import logging
from logging import StreamHandler
# ========== Setup formatters ==========
# ========== END: Setup formatters ==========
def loglevel(app):
"""'Compute' the LOGLEVEL from the application."""
return logging.DEBUG if app.config.get("DEBUG", False) else logging.WARNING
def setup_app_handlers(app):
"""Setup the logging handlers for the application `app`."""
# ========== Setup handlers ==========
stderr_handler = StreamHandler(stream=sys.stderr)
app.logger.addHandler(stderr_handler)
# ========== END: Setup handlers ==========
root_logger = logging.getLogger()
root_logger.addHandler(stderr_handler)
root_logger.setLevel(loglevel(app))
|