Skip to main content

Library with nice preset logging handlers for logging library

Project description

GitHub last commit GitHub license<space><space> Documentation Status https://travis-ci.org/stas-prokopiev/logging_nice_handlers.svg?branch=master PyPI PyPI - Python Version

Overview.

This library consists of different logging handlers which I see usefull in different projects.

Installation via pip:

pip install char

logging Handlers

AllLevelFileHandler

This handler quite similar to logging.FileHandler but instead of FileHandler
it saves not in one file but in separate file for every level
So as the results in some directory you will get files
  • debug_msgs.txt - For all messages for levels logging.DEBUG and above

  • info_msgs.txt - For all messages for levels logging.INFO and above

  • warning_msgs.txt - For all messages for levels logging.WARNING and above

  • error_msgs.txt - For all messages for levels logging.ERROR and above

Such structure of logs can be quite usefull if your projected is expected to be used by externel users
So in case of some errors all these files with logs can be sent to the author and be analyzed.
import logging
from logging_nice_handlers import AllLevelFileHandler

LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(10)
LOGGER.addHandler(
    AllLevelFileHandler(
        str_path_dir_with_logs="Logs",
        str_open_mode="w",
    )
)
LOGGER.info("Hi friend!")

JupyterStreamHandler

This handler is the replacement for logging.StreamHandler when it should be used in jupyter notebooks
It will highlight in red all messages with the level which is above some set level.
So you won’t miss that the warnings or errors are happening in you programm.
import logging
from logging_nice_handlers import JupyterStreamHandler

LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(10)
LOGGER.addHandler(
    JupyterStreamHandler(
        int_min_stdout_level=logging.INFO,
        int_min_stderr_level=logging.WARNING,
    )
)
LOGGER.warning("Hi friend!")

Contacts

License

This project is licensed under the MIT License.

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

logging_nice_handlers-0.1.0.tar.gz (16.8 kB view hashes)

Uploaded Source

Built Distribution

logging_nice_handlers-0.1.0-py2.py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 2 Python 3

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