Skip to content

Programmatically creates python loggers with different handlers (console, file, graylog)

License

Notifications You must be signed in to change notification settings

Ouest-France/sipy_logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sipy_logger

Programmatically creates python loggers with different handlers (console, file, graylog)

Install

Install from the github repository:

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

Usage

  • 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)

Licence

Unless stated otherwise all works are:

  • Copyright © Ouest-France/SIPA Tech
  • licensed under the MIT license, a copy of which is included here

Contributions

Pull-requests are welcome and will be processed on a best-effort basis.

About

Programmatically creates python loggers with different handlers (console, file, graylog)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages