Programmatically creates python loggers with different handlers (console, file, graylog)
Install from the github repository:
- with pipenv:
pipenv install git https://github.com/Ouest-France/sipy_logger.git#egg=sipy_logger
- with
pip
:
pip3 install git https://github.com/Ouest-France/sipy_logger.git
- fully declare the logger in the root script (eg.
server.py
):
from os import getenv
LOG_DIR = getenv('LOG_DIR')
from sipy_logger import getLogger
logger = getLogger('myapplogger', fileDir=LOG_DIR, filename=datetime.now().strftime('%Y-%m-%d_%H:%M:%S.%m-myapp.log'))
from ./routehandler import routehandler
# ...
logger.info('starting server, logging in %s', LOG_DIR)
- re-use it in sub-scripts (eg.
routehandler.py
) that are imported by the root script:
from sipy_logger import getLogger
logger = getLogger('myapplogger') # no need to re-specify the logger parameters, they would be ignored anyway
logger.info('handling route %s', aRoute)
Unless stated otherwise all works are:
- Copyright © Ouest-France/SIPA Tech
- licensed under the MIT license, a copy of which is included here
Pull-requests are welcome and will be processed on a best-effort basis.