rainbow_logging_handler
=======================
.. image:: https://travis-ci.org/laysakura/rainbow_logging_handler.png?branch=master
:target: https://travis-ci.org/laysakura/rainbow_logging_handler
.. image:: https://pypip.in/v/rainbow_logging_handler/badge.png
:target: https://pypi.python.org/pypi/rainbow_logging_handler
:alt: Latest PyPI version
Ultimate Python colorized logger.
.. contents:: :local:
Usage
-----
Generic usage example
#####################
.. image:: http://github.com/laysakura/rainbow_logging_handler/raw/master/doc/screenshot.png
This script runs like above screenshot.
.. code-block:: python
import sys
import logging
from rainbow_logging_handler import RainbowLoggingHandler
def main_func():
# setup `logging` module
logger = logging.getLogger('test_logging')
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter("[%(asctime)s] %(name)s %(funcName)s():%(lineno)d\t%(message)s") # same as default
# setup `RainbowLoggingHandler`
handler = RainbowLoggingHandler(sys.stderr, color_funcName=('black', 'yellow', True))
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.debug("debug msg")
logger.info("info msg")
logger.warn("warn msg")
logger.error("error msg")
logger.critical("critical msg")
try:
raise RuntimeError("Opa!")
except Exception as e:
logger.exception(e)
if __name__ == '__main__':
main_func()
Usage with Django
##################################
.. image:: http://github.com/miohtama/rainbow_logging_handler/raw/master/doc/screenshot_django.png
`Django <https://www.djangoproject.com/>`_ is a popular Python web framework.
Put the following to your ``settings.py`` to get more pleasant development server console output::
# Add this to your settings.py
if DEBUG:
# Install rainbow logging handler when running Django in develoment mode
import sys
LOGGING["handlers"]["rainbow"] = {"level": "DEBUG", "class": "rainbow_logging_handler.RainbowLoggingHandler", 'stream': sys.stderr}
LOGGING["loggers"]['']["handlers"].append("rainbow")
`More about configuring loggers for Django <https://docs.djangoproject.com/en/dev/topics/logging/>`_.
Features
--------
Column-by-column colored log
############################
As apparent from above screenshot, each column of logs are differently colored.
Even default coloring should make log reading easier.
User custom color
#################
Every column colors are **customizable**.
.. code-block:: python
formatter = logging.Formatter('%(pathname)s [%(module)s] - %(funcName)s:L%(lineno)d : %(message)s')
handler = RainbowLoggingHandler(
sys.stderr,
# Customizing each column's color
color_pathname=('black', 'red' , True), color_module=('yellow', None, False),
color_funcName=('blue' , 'white', True), color_lineno=('green' , None, False),
)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.info("hello custom world")
Above code produces output like this.
.. image:: http://github.com/laysakura/rainbow_logging_handler/raw/master/doc/screenshot-custom-color.png
High portability
################
Linux, BSD, Mac OS, and Windows are supposed to be supported.
Runs with both Python 2.6 or higher & Python 3.2 or higher.
Install
-------
Install from PyPI
#################
.. code-block:: bash
$ pip install rainbow_logging_handler
Install from Github repo
########################
.. code-block:: bash
$ git clone https://github.com/laysakura/rainbow_logging_handler.git
$ cd rainbow_logging_handler
$ ./setup.py install
Author
------
Mikko Ohtamaa <mikko@opensourcehacker.com>, Sho Nakatani <lay.sakura@gmail.com>
And special thanks to `10sr <https://github.com/10sr>`_ for advice.
License
-------
This is free and unencumbered public domain software. For more information,
see <http://unlicense.org/> or the accompanying `LICENSE.txt` file.
Raw data
{
"_id": null,
"home_page": "https://github.com/laysakura/rainbow_logging_handler",
"name": "rainbow_logging_handler",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Mikko Ohtamaa, Sho Nakatani",
"author_email": "mikko@opensourcehacker.com, lay.sakura@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3d/15/aa3cd5c46c709b2bc45e3f8612b6484bbc869d43f92dfc4a86b65e6a240a/rainbow_logging_handler-2.2.2.zip",
"platform": "UNKNOWN",
"description": "rainbow_logging_handler\n=======================\n.. image:: https://travis-ci.org/laysakura/rainbow_logging_handler.png?branch=master\n :target: https://travis-ci.org/laysakura/rainbow_logging_handler\n\n.. image:: https://pypip.in/v/rainbow_logging_handler/badge.png\n :target: https://pypi.python.org/pypi/rainbow_logging_handler\n :alt: Latest PyPI version\n\nUltimate Python colorized logger.\n\n.. contents:: :local:\n\nUsage\n-----\n\nGeneric usage example\n#####################\n.. image:: http://github.com/laysakura/rainbow_logging_handler/raw/master/doc/screenshot.png\n\nThis script runs like above screenshot.\n\n.. code-block:: python\n\n import sys\n import logging\n from rainbow_logging_handler import RainbowLoggingHandler\n\n def main_func():\n # setup `logging` module\n logger = logging.getLogger('test_logging')\n logger.setLevel(logging.DEBUG)\n formatter = logging.Formatter(\"[%(asctime)s] %(name)s %(funcName)s():%(lineno)d\\t%(message)s\") # same as default\n\n # setup `RainbowLoggingHandler`\n handler = RainbowLoggingHandler(sys.stderr, color_funcName=('black', 'yellow', True))\n handler.setFormatter(formatter)\n logger.addHandler(handler)\n\n logger.debug(\"debug msg\")\n logger.info(\"info msg\")\n logger.warn(\"warn msg\")\n logger.error(\"error msg\")\n logger.critical(\"critical msg\")\n\n try:\n raise RuntimeError(\"Opa!\")\n except Exception as e:\n logger.exception(e)\n\n if __name__ == '__main__':\n main_func()\n\n\nUsage with Django\n##################################\n.. image:: http://github.com/miohtama/rainbow_logging_handler/raw/master/doc/screenshot_django.png\n\n`Django <https://www.djangoproject.com/>`_ is a popular Python web framework.\n\nPut the following to your ``settings.py`` to get more pleasant development server console output::\n\n # Add this to your settings.py\n if DEBUG:\n # Install rainbow logging handler when running Django in develoment mode\n import sys\n LOGGING[\"handlers\"][\"rainbow\"] = {\"level\": \"DEBUG\", \"class\": \"rainbow_logging_handler.RainbowLoggingHandler\", 'stream': sys.stderr}\n LOGGING[\"loggers\"][''][\"handlers\"].append(\"rainbow\")\n\n`More about configuring loggers for Django <https://docs.djangoproject.com/en/dev/topics/logging/>`_.\n\n\nFeatures\n--------\n\nColumn-by-column colored log\n############################\nAs apparent from above screenshot, each column of logs are differently colored.\nEven default coloring should make log reading easier.\n\nUser custom color\n#################\nEvery column colors are **customizable**.\n\n.. code-block:: python\n\n formatter = logging.Formatter('%(pathname)s [%(module)s] - %(funcName)s:L%(lineno)d : %(message)s')\n handler = RainbowLoggingHandler(\n sys.stderr,\n # Customizing each column's color\n color_pathname=('black', 'red' , True), color_module=('yellow', None, False),\n color_funcName=('blue' , 'white', True), color_lineno=('green' , None, False),\n )\n handler.setFormatter(formatter)\n logger.addHandler(handler)\n logger.info(\"hello custom world\")\n\nAbove code produces output like this.\n\n.. image:: http://github.com/laysakura/rainbow_logging_handler/raw/master/doc/screenshot-custom-color.png\n\nHigh portability\n################\nLinux, BSD, Mac OS, and Windows are supposed to be supported.\n\nRuns with both Python 2.6 or higher & Python 3.2 or higher.\n\nInstall\n-------\n\nInstall from PyPI\n#################\n.. code-block:: bash\n\n $ pip install rainbow_logging_handler\n\nInstall from Github repo\n########################\n.. code-block:: bash\n\n $ git clone https://github.com/laysakura/rainbow_logging_handler.git\n $ cd rainbow_logging_handler\n $ ./setup.py install\n\nAuthor\n------\n\nMikko Ohtamaa <mikko@opensourcehacker.com>, Sho Nakatani <lay.sakura@gmail.com>\n\nAnd special thanks to `10sr <https://github.com/10sr>`_ for advice.\n\nLicense\n-------\n\nThis is free and unencumbered public domain software. For more information,\nsee <http://unlicense.org/> or the accompanying `LICENSE.txt` file.",
"bugtrack_url": null,
"license": "LICENSE.txt",
"summary": "Ultimate Python colorized logger with user-custom color",
"version": "2.2.2",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/laysakura/rainbow_logging_handler"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3d15aa3cd5c46c709b2bc45e3f8612b6484bbc869d43f92dfc4a86b65e6a240a",
"md5": "e24f2cfa9d7f32dafcc6faffae62ee81",
"sha256": "a504c20f1e074cc7f5a5b986c08eb6fb495c9153cffb36b5fa0a587de3a8db63"
},
"downloads": -1,
"filename": "rainbow_logging_handler-2.2.2.zip",
"has_sig": false,
"md5_digest": "e24f2cfa9d7f32dafcc6faffae62ee81",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15109,
"upload_time": "2014-08-06T23:43:22",
"upload_time_iso_8601": "2014-08-06T23:43:22.887228Z",
"url": "https://files.pythonhosted.org/packages/3d/15/aa3cd5c46c709b2bc45e3f8612b6484bbc869d43f92dfc4a86b65e6a240a/rainbow_logging_handler-2.2.2.zip",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2014-08-06 23:43:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "laysakura",
"github_project": "rainbow_logging_handler",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"lcname": "rainbow_logging_handler"
}