{ "info": { "author": "Pat Daburu", "author_email": "pat@daburu.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": "logpp\n=====\n\nWhy *logpp*?\n------------\n\nlogpp is a fairly simple module that contains some extensions for\nPython\u2019s built in logging module. It provides a few facilities that\nallow you to pass extended information with logging messages.\n\nThe three principle components are listed below.\n\n- `logpp.logging.msg() `__\n- `logpp.logging.LogppMessage `__\n- `logpp.logging.LogppHandler `__\n\nThe module also provides the\n`LogppMixin `__\nwhich you can use to provide standardized access to a logger via the\n`LogppMixin.logger `__\nmethod.\n\nLogging a Message\n-----------------\n\nThe example below has been expanded to make the components easier to\nsee, but it\u2019s actually a fairly simple one-liner. The\n`msg() `__\nfunction takes a summary str and a detail object (which in the example\nis just a dictionary).\n\nThe function returns a\n`LogppMessage `__\nwhich, when represented in str form is simply the summary.\n\n.. code:: python\n\n logging.info(\n msg(\n 'The weather is currently sunny with a temperature of 25\u00b0C.',\n {\n 'conditions': 'sunny',\n 'temperature': 25\n }\n )\n )\n\nLogging handlers that aren\u2019t aware of the detail information should\nsimply see the *logpp* message as the summary.\n\nHandling Messages\n-----------------\n\nIf you\u2019re using *logpp*, chances are you want to do something useful or\nclever with the detail information. To accomplish that you can create\nyour own logging handler. If your custom handler is only interested in\nlogpp messages, you can extend the\n`LogppHandler `__\nand override the\n`emit\\_logpp() `__\nmethod. The base class will perform checks to make sure that only\nlogging messages that are instances of the\n`LogppMessage `__\nclass are passed to this method.\n\nPutting It All Together\n-----------------------\n\nThe sample below briefly demonstrates the creation of a custom log\nhandler and should give you an idea of what to expect from such a\nfacility.\n\n.. code:: python\n\n import logging\n from logpp.logging import msg, LogppMessage, LogppHandler\n\n\n # Create a custom handler.\n class CustomLogppHandler(LogppHandler):\n\n def emit_logpp(self, msg_: LogppMessage):\n print(f'SUMMARY: {msg_.summary}')\n print(f'DETAILS: {msg_.detail}')\n\n\n logging.basicConfig(level=logging.INFO)\n # Add the custom handler to the logger (just as you would with any handler).\n logging.getLogger().addHandler(CustomLogppHandler())\n\n # Log a message to be handled by the custom handler.\n logging.info(\n msg(\n 'The weather is currently sunny with a temperature of 25\u00b0C.',\n {\n 'conditions': 'sunny',\n 'temperature': 25\n }\n )\n )\n\n # Log a message that will be ignored by the custom handler.\n logging.info('This message will be ignored by the custom handler.')\n\nUsing the *LogppMixin*\n----------------------\n\nLet\u2019s say you have a class that needs to log its activities. Often\nyou\u2019ll want to use a named logger. This can involve a few lines of\nboiler plate which can be a bit tedious to produce in every class. By\nextending the\n`LogppMixin `__\nyour class gains the\n`logger() `__\nfunction which returns a logger with a name that reflects the name of\nthe class (though you can override that behavior by adding a\n``__loggername__`` attribute to the class).\n\n.. code:: python\n\n import logging\n from logpp.logging import LogppMixin\n\n\n # Just so we may demonstrate the use of the mixin, here's a base class\n # that has nothing to do with logging from which we can inherit.\n class SampleBaseClass(object):\n pass\n\n\n # Now let's create a class that extends the sample base class, but\n # which also mixes in the logging facility.\n class LoggableClass(SampleBaseClass, LogppMixin):\n\n def log_something(self):\n self.logger().info('Hello world!')\n\n\n # Set up basic logging\n logging.basicConfig(level=logging.INFO)\n\n # Create a new instance of the mixed-in class...\n loggable = LoggableClass()\n # ...and ask it to log something.\n loggable.log_something()\n\nResources\n---------\n\nWould you like to learn more? Check out the links below!\n\n- `Read the Docs `__\n- `Logging HOWTO `__\n\nAuthors\n-------\n\n- **Pat Daburu** - *Initial work* -\n `github `__\n\nSee also the list of\n`contributors `__\nwho participated in this project.\n\nLicense\n-------\n\nThis project is licensed under the MIT License - see the\n`LICENSE.md `__ file for details", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/patdaburu/logpp/archive/0.0.8.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://logpp.readthedocs.io/en/latest/index.html", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "logpp", "package_url": "https://pypi.org/project/logpp/", "platform": "", "project_url": "https://pypi.org/project/logpp/", "project_urls": { "Download": "https://github.com/patdaburu/logpp/archive/0.0.8.tar.gz", "Homepage": "http://logpp.readthedocs.io/en/latest/index.html" }, "release_url": "https://pypi.org/project/logpp/0.0.8/", "requires_dist": null, "requires_python": ">=3.6", "summary": "python logging extensions", "version": "0.0.8" }, "last_serial": 5349536, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0186c6e7d72aae21b57954845ab37672", "sha256": "79e13aca64c2fe92f5ba9ad3df216b30932eba0b301869049f9df1976a38bced" }, "downloads": -1, "filename": "logpp-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0186c6e7d72aae21b57954845ab37672", "packagetype": "sdist", "python_version": "source", "requires_python": ">=0.0.1", "size": 2746, "upload_time": "2018-07-05T22:07:56", "url": "https://files.pythonhosted.org/packages/b0/4e/e7f1f47c2c13a82a6ddf59e8f7c2f802107f9a4f0c7c6e1ab52653d710c7/logpp-0.0.1.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "0063bf4c4424794a518806ddd2db0410", "sha256": "166c70e8e874417c7d1849d402c5b96cf622aa9e836df8f0e1b85b3d4aa5fedd" }, "downloads": -1, "filename": "logpp-0.0.3.tar.gz", "has_sig": false, "md5_digest": "0063bf4c4424794a518806ddd2db0410", "packagetype": "sdist", "python_version": "source", "requires_python": ">=0.0.1", "size": 2612, "upload_time": "2018-07-06T15:04:56", "url": "https://files.pythonhosted.org/packages/c0/cb/17c06baafbd3f4d5dab279261972860cf914a9234e61dc2e91fa266411e5/logpp-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "319697f1799d154e0f0ed64cf052a836", "sha256": "3f6d788326249f82646e21224de794d73e7bbb824872d14087ba50ea28eaadd2" }, "downloads": -1, "filename": "logpp-0.0.4.tar.gz", "has_sig": false, "md5_digest": "319697f1799d154e0f0ed64cf052a836", "packagetype": "sdist", "python_version": "source", "requires_python": ">=0.0.1", "size": 3073, "upload_time": "2018-07-06T18:03:22", "url": "https://files.pythonhosted.org/packages/4d/4c/7ad258345935d6481d9e74f9b725cad9693c6d8e32122cf1e3011fd4ea49/logpp-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "6c2db1e25ee183eceeb483e57d2c50cd", "sha256": "7f8bfbb024b431301a98532be0279d01f4d613aa0c3a9c30459a516bbe157242" }, "downloads": -1, "filename": "logpp-0.0.5.tar.gz", "has_sig": false, "md5_digest": "6c2db1e25ee183eceeb483e57d2c50cd", "packagetype": "sdist", "python_version": "source", "requires_python": ">=0.0.1", "size": 3069, "upload_time": "2018-07-06T21:56:05", "url": "https://files.pythonhosted.org/packages/5f/35/2567e1bd0b2d6cd292cfb16f69844952f78eab965d9e3e84e935a550f4fc/logpp-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "347e31310e69864dea9f183134dedab5", "sha256": "7b509f4ed4c28d316b48d5d332718310980ab6bea8011bf41e11889fcf5d6924" }, "downloads": -1, "filename": "logpp-0.0.6.tar.gz", "has_sig": false, "md5_digest": "347e31310e69864dea9f183134dedab5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=0.0.1", "size": 5082, "upload_time": "2018-07-07T13:58:47", "url": "https://files.pythonhosted.org/packages/93/cf/b43b03635d67687f6c552d4e2e69b105695cb3fec9c4ffd9b937e347d9e5/logpp-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "5fb9fe13a160e87d374e3c0f1ac06d27", "sha256": "5cd8680022ab9e78fee0447aacaa59bb97d48d34d58cb3622c091ce52c8e182d" }, "downloads": -1, "filename": "logpp-0.0.7.tar.gz", "has_sig": false, "md5_digest": "5fb9fe13a160e87d374e3c0f1ac06d27", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5277, "upload_time": "2018-07-07T15:22:12", "url": "https://files.pythonhosted.org/packages/a4/08/5992a76d259b7fdb3f124e79611be44a307d50ac1bbd1b041b94f0bbc2b4/logpp-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "fe8fb4ee66b95d8b34bc2ee63100c4ed", "sha256": "cb938f27cf9203aa7d192d5265889b0a2b29bde83e7ad1a4c2a0d99f81ad064d" }, "downloads": -1, "filename": "logpp-0.0.8.tar.gz", "has_sig": false, "md5_digest": "fe8fb4ee66b95d8b34bc2ee63100c4ed", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5491, "upload_time": "2019-06-02T18:26:59", "url": "https://files.pythonhosted.org/packages/12/58/d1aa1c75ee70b23127e9dc461e1d02f022e707e558e9cfe4de0909c1a8a9/logpp-0.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fe8fb4ee66b95d8b34bc2ee63100c4ed", "sha256": "cb938f27cf9203aa7d192d5265889b0a2b29bde83e7ad1a4c2a0d99f81ad064d" }, "downloads": -1, "filename": "logpp-0.0.8.tar.gz", "has_sig": false, "md5_digest": "fe8fb4ee66b95d8b34bc2ee63100c4ed", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5491, "upload_time": "2019-06-02T18:26:59", "url": "https://files.pythonhosted.org/packages/12/58/d1aa1c75ee70b23127e9dc461e1d02f022e707e558e9cfe4de0909c1a8a9/logpp-0.0.8.tar.gz" } ] }