{ "info": { "author": "Eric Crosson", "author_email": "eric.s.crosson@utexas.edu", "bugtrack_url": null, "classifiers": [], "description": "Stump\n=====\n\n.. image:: https://travis-ci.org/EricCrosson/stump.svg?branch=master\n :target: https://travis-ci.org/EricCrosson/stump\n :alt: Travis-CI Build Status\n.. image:: https://img.shields.io/pypi/v/stump.svg\n :target: https://github.com/EricCrosson/stump\n :alt: Current Version\n.. image:: https://img.shields.io/pypi/l/stump.svg\n :target: https://github.com/EricCrosson/stump\n :alt: License\n\n- `What is stump?`_\n\n- `Installation`_\n\n- `Usage`_\n\n - `API`_\n\n - `Examples`_\n\n- `License`_\n\n.. role:: python(code)\n :language: python\n\nWhat is stump?\n--------------\n\n**Stump:**\n\n*n.* the lower end of a tree or plant left after the main part is\nremoved\n\n**Log:**\n\n*n.* a portion or length of the trunk or of a large limb of a felled\ntree\n\n:python:`stump` is a **logging utility for Python** that uses the `standard\nlogging module`_ under the covers. However, a stump is a different part of a\ntree than a log and as such should be utilized differently. :Python:`stump`\noffers various `method decorators`_ that really cover all the bases of logging\nfor debugging. :Python:`stump`\u2019s method decorators are flexible and concise, act\nas additional documentation, don\u2019t clutter the main code of the method body and\naccept a natural format string that is easy to form and read.\n\nInstallation\n------------\n\nInstall from `pip`_\n\n.. code-block:: bash\n\n pip install stump\n\nAlternatively, clone this repo and install from your local copy\n\n.. code-block:: bash\n\n git clone https://github.com/EricCrosson/stump\n cd stump\n python setup.py install\n\n\nUsage\n-----\n\nOnce installed simply :python:`import stump` and pass a logger to\n:python:`stump.configure`, as demonstrated in the `Examples`_ section.\n\nThe different :python:`stump` decorators all inherit the same functionality,\nwith minor behavioral differences. Each decorator accepts a logging string as\nthe first argument. This string may contain the values of the decorated method's\nparameters. For example, to log the values of parameters passed to\n:python:`accelerate` the following format string could be used\n\n.. code-block:: python\n\n @stump.put('Object is {weight} lbs with {gravity} m/s^2 acceleration')\n def accelerate(weight, gravity):\n work()\n\n\nIf invoked by :python:`accelerate(42, 9.8)` the logs generated would be\n\n.. code-block:: text\n\n INFO:accelerate:Object is 42 lbs with 9.8 m/s^2 acceleration...\n INFO:accelerate:Object is 42 lbs with 9.8 m/s^2 acceleration...done\n\nAPI\n~~~\n\nThe standard decorator, :python:`stump.put`, prints a message upon entering and\nexiting a method. The below table describes the public api exposed by :python:`stump`.\n\n:python:`stump.put`\n Print a message upon entering and exiting the method\n\n:python:`stump.pre`\n Print a message only upon entering the method\n\n:python:`stump.post`\n Print a message only upon exiting the method\n\n:python:`stump.date`\n Like :python:`stump.put`, but include a date- and time- stamp\n\n:python:`stump.ret`\n Like :python:`stump.put`, but include the method's return value\n\n\nExamples\n~~~~~~~~\n\nImport the :python:`stump` library and configure the :python:`stump` logger\n\n.. code-block:: python\n\n #!/usr/bin/env python\n import stump\n\n # configure a logger for stump\n import sys\n import logging\n logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)\n logger = logging.getLogger()\n\n stump.configure(logger)\n\nAnd decorate some methods. :Python:`stump` allows you to interpolate a string\nrepresentation of the parameter values to decorated methods by simply\nwrapping the parameter name in curly braces.\n\n.. code-block:: python\n\n @stump.post('Using nitrous')\n def use_nitrous():\n raise NoNitrousException('You never installed nitrous!')\n\n @stump.ret('\"Calculating\" boost for car {car}')\n def car_boost(car):\n try:\n use_nitrous()\n except:\n return random.random() * 100\n\n @stump.pre()\n def ready():\n light = 'red'\n\n @stump.pre()\n def set():\n light = 'yellow'\n\n @stump.post()\n def go():\n light = 'green'\n\n @stump.date('Racing {car}', print_return=True)\n def race(car):\n luck = car_boost(car)\n return random.randint(1, round(luck))\n\n ready()\n set()\n go()\n race('wacky')\n\nThis example logs the following events\n\n.. code:: text\n\n INFO:root:ready...\n INFO:root:set...\n INFO:root:go...done\n INFO:root:race:2016-02-14 23:33:37:Racing wacky...\n INFO:root:car_boost:\"Calculating\" boost for car wacky...\n INFO:root:use_nitrous:Using nitrous...\n INFO:root:use_nitrous:Using nitrous...threw exception NoNitrousException with message You never installed nitrous!\n INFO:root:car_boost:\"Calculating\" boost for car wacky...done (returning 56.138089977332776)\n INFO:root:race:2016-02-14 23:33:37:Racing wacky...done (returning 2)\n\nLicense\n-------\n\nThis code is released under the MIT license.\n\n.. _What is stump?: #what-is-stump\n.. _Installation: #installation\n.. _Usage: #usage\n.. _License: #license\n.. _API: #api\n.. _Examples: #examples\n.. _standard logging module: https://docs.python.org/3/library/logging.html\n.. _method decorators: https://www.python.org/dev/peps/pep-0318/\n.. _pip: https://pypi.python.org/pypi/pip", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/EricCrosson/stump", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "stump", "package_url": "https://pypi.org/project/stump/", "platform": "", "project_url": "https://pypi.org/project/stump/", "project_urls": { "Homepage": "http://github.com/EricCrosson/stump" }, "release_url": "https://pypi.org/project/stump/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Logs program flow with decorators", "version": "1.0.0" }, "last_serial": 4474541, "releases": { "0.11": [ { "comment_text": "", "digests": { "md5": "8c395e16e1efb6ff37efc22578d77c52", "sha256": "68a675d3f94a2774f868f41d0039b14b36474f10a485b3e73bfcebbe10f0c441" }, "downloads": -1, "filename": "stump-0.11.tar.gz", "has_sig": false, "md5_digest": "8c395e16e1efb6ff37efc22578d77c52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3872, "upload_time": "2016-02-15T00:04:39", "url": "https://files.pythonhosted.org/packages/2a/71/496ec5e1fc7dce2b6ff34815442621bc21ff115aff22aeb500f33f7acb22/stump-0.11.tar.gz" } ], "0.12": [ { "comment_text": "", "digests": { "md5": "d307fa68a3e7a3da272a0925b4106d42", "sha256": "5e0cffe4bc7f44b6bc25724b2c21e30974e1cbaf152a56f2ef371f7310702ee0" }, "downloads": -1, "filename": "stump-0.12.tar.gz", "has_sig": false, "md5_digest": "d307fa68a3e7a3da272a0925b4106d42", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4866, "upload_time": "2016-02-15T03:17:58", "url": "https://files.pythonhosted.org/packages/07/40/92f17ecd6e2b8e68e6a7e8172e2387e0474b2221e20690a7514d24c99e36/stump-0.12.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "0ff60b61de76a16ae46f271a4c8be3ee", "sha256": "60dcbe38e69b08efe90aea22b69398a1f20417940b4ef9dffa47a7a3c9c02151" }, "downloads": -1, "filename": "stump-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0ff60b61de76a16ae46f271a4c8be3ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5365, "upload_time": "2018-11-11T15:15:26", "url": "https://files.pythonhosted.org/packages/33/67/c2f0ca1976f7c37f7452e9e1c93a0ea8d80aa5f7bd70515236692a7389e4/stump-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0ff60b61de76a16ae46f271a4c8be3ee", "sha256": "60dcbe38e69b08efe90aea22b69398a1f20417940b4ef9dffa47a7a3c9c02151" }, "downloads": -1, "filename": "stump-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0ff60b61de76a16ae46f271a4c8be3ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5365, "upload_time": "2018-11-11T15:15:26", "url": "https://files.pythonhosted.org/packages/33/67/c2f0ca1976f7c37f7452e9e1c93a0ea8d80aa5f7bd70515236692a7389e4/stump-1.0.0.tar.gz" } ] }