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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file logging_nice_handlers-0.1.0.tar.gz.

File metadata

  • Download URL: logging_nice_handlers-0.1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for logging_nice_handlers-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2648954fa4b3798909221759ecbd0b295c9807f17148f7c7e465fd35f2a7f1c9
MD5 1a4779b814ba19ed22cdaa198b2042e8
BLAKE2b-256 30139f159342566b338deca46a88a752e1b51ca2bf7e0dcad31dd195a9ee2918

See more details on using hashes here.

File details

Details for the file logging_nice_handlers-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: logging_nice_handlers-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for logging_nice_handlers-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9e77dd571486f1f5f26b112506cceeba58adece9adb964a590c19cee71fb8558
MD5 326037fd181f4c9992043af9907c4b5f
BLAKE2b-256 9c0bf39fc5f0f57466a72ce0fb8f94bf873150d45c8d0797dfff307d48c7911f

See more details on using hashes here.

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