Skip to main content

Python logger used at Alkivi

Project description

Build Status Requirements Status

Python logger used at Alkivi

Package

Example

import logging

from alkivi.logger import Logger

#
# Define Logger
#
l = logging.getLogger(__name__)
logger = Logger(l,
                min_log_level_to_mail=None,
                min_log_level_to_save=logging.DEBUG,
                min_log_level_to_print=logging.DEBUG,
                min_log_level_to_syslog=None,
                emails=['anthony@alkivi.fr'])

#
# All log level, from bottom to top
#
logger.debug('This is a debug comment')
logger.info('This is an info comment')
logger.warning('This is a warning comment')
logger.error('This is an error comment')
logger.critical('This is a critical comment')

try:
    1/0
except Exception as e:
    logger.exception('This is an exception comment')
    pass

#
# You can adjust log level on the fly
#
logger.set_min_level_to_mail(logging.WARNING)
logger.set_min_level_to_save(logging.WARNING)

#
# You can use loops
#
logger.new_loop_logger()
for i in range(0, 11):
    logger.new_iteration(prefix='i=%i' % (i))
    logger.debug("We are now prefixing all logger")
    if i == 9:
        logger.debug("Lets do another loop")
        logger.new_loop_logger()
        for j in range(0, 5):
            logger.new_iteration(prefix='j=%i' % (j))
            logger.debug("Alkivi pow@")

        # Dont forget to close logger or shit will happen
        logger.del_loop_logger()
    # Bonus point : if emailing is set, only send email for the loop we have
    # error
    if i == 10:
        logger.critical("We shall receive only mail for last loop")

logger.del_loop_logger()
logger.debug('We now remove an loop, thus a prefix')

Tests

Testing is set up using pytest and coverage is handled with the pytest-cov plugin.

Run your tests with py.test in the root directory.

Coverage is ran by default and is set in the pytest.ini file. To see an html output of coverage open htmlcov/index.html after running the tests.

TODO

Travis CI

There is a .travis.yml file that is set up to run your tests for python 2.7 and python 3.2, should you choose to use it.

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alkivi-logger-1.1.2.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

alkivi_logger-1.1.2-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file alkivi-logger-1.1.2.tar.gz.

File metadata

File hashes

Hashes for alkivi-logger-1.1.2.tar.gz
Algorithm Hash digest
SHA256 4fd54ce427866a5c46ee686ebe02ed294679c80c7af44aca2ec620351eba2889
MD5 3b9f9f56da907ec7a13ff42b5b567916
BLAKE2b-256 92c7ef762fd0e8c05d345aae0bc9f4df7278a9a0dca395db5ac7ef5310c387e9

See more details on using hashes here.

Provenance

File details

Details for the file alkivi_logger-1.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for alkivi_logger-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 627b2967b3d656580806166409eac235b5cdcdca04cd5c6ceb744a7efeca253a
MD5 909c9c709712f9b160652175844b32e1
BLAKE2b-256 2cc1323175315c6d1c6f53be99120ecc8e61464e1eb0c2a2521f2b83355b35c6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page