belogging


Namebelogging JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryEasy and opinionated logging configuration for Python apps
upload_time2024-12-18 20:00:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2016 George Kussumoto Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Belogging
=========

*Don't fight with logging ...*

|Coverage Status| |PyPI Version| |PyPI License| |PyPI latest|

----

Easy logging configuration based on environment variables.

Features:

* Set logging level using environment variable LOG_LEVEL (defaults to `INFO`)
* Set which loggers to enable using environment variable `LOGGERS` (defaults to `''`, everything)
* Always output to stdout
* Optional JSON formatter
* Completely disable logging setting `LOG_LEVEL=DISABLED`

Requirements:

* Python 3.10+

Install:

.. code-block:: bash

   pip install belogging


Examples:
---------

Simple applications:
~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    # my_script.py

    import belogging
    belogging.load()
    # ^^ this call is optional, only useful for customization
    # For example, to enable JSON output: belogging.load(json=True)

    # belogging.getLogger is just a sugar to logging.getLogger, you can
    # use logging.getLogger as usual (and recommended).
    logger = belogging.getLogger('foobar')
    logger.debug('test 1')
    logger.info('test 2')


Executing:

.. code-block:: bash

    # selecting LOG_LEVEL
    $ LOG_LEVEL=DEBUG python my_script.py
    # level=DEBUG message=test 1
    # level=INFO message=test 2

    # selecting LOGGERS
    $ LOGGERS=foobar python my_script.py
    # Both messages

    # Both
    $ LOGGERS=foobar LOG_LEVEL=INFO my_script.py
    # only level=INFO message=test 2


Applications should call ```belogging.load()``` upon initialization.
The first ```__init__.py``` would be a good candidate, but anything before any call to
```logging``` module will be fine.


Django:
~~~~~~~


In your projects ```settings.py```:

.. code-block:: python

    import belogging
    # Disable django logging setup
    LOGGING_CONFIG = None
    belogging.load()


Inside your code, just use ```logging.getLogger()``` as usual.

.. code-block:: bash

    $ export LOG_LEVEL=WARNING
    $ ./manage.py runserver
    # It will output only logging messages with severity > WARNING


Logging follows a hierarchy, so you easily select or skip some logging messages:


.. code-block:: bash

    $ export LOGGERS=my_app.critical_a,my_app.critical_c,my_lib
    $ ./my-app.py
    # "my_app.critical_b messages" will be skipped
    # all messages from my_lib will show up


.. |Coverage Status| image:: https://coveralls.io/repos/github/georgeyk/belogging/badge.svg?branch=master
   :target: https://coveralls.io/github/georgeyk/belogging?branch=master
.. |PyPI Version| image:: https://img.shields.io/pypi/pyversions/belogging.svg?maxAge=2592000
   :target: https://pypi.python.org/pypi/belogging
.. |PyPI License| image:: https://img.shields.io/pypi/l/belogging.svg?maxAge=2592000
   :target: https://pypi.python.org/pypi/belogging
.. |PyPI latest| image:: https://img.shields.io/pypi/v/belogging.svg?maxAge=2592000
   :target: https://pypi.python.org/pypi/belogging

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "belogging",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "logging",
    "author": null,
    "author_email": "\"George Y. Kussumoto\" <contato@georgeyk.com.br>",
    "download_url": "https://files.pythonhosted.org/packages/4d/64/e0a91b7d8a9fafcdf795b7c1e909e4e2d3839d253aed5da69fb0eda64f01/belogging-0.2.0.tar.gz",
    "platform": null,
    "description": "Belogging\n=========\n\n*Don't fight with logging ...*\n\n|Coverage Status| |PyPI Version| |PyPI License| |PyPI latest|\n\n----\n\nEasy logging configuration based on environment variables.\n\nFeatures:\n\n* Set logging level using environment variable LOG_LEVEL (defaults to `INFO`)\n* Set which loggers to enable using environment variable `LOGGERS` (defaults to `''`, everything)\n* Always output to stdout\n* Optional JSON formatter\n* Completely disable logging setting `LOG_LEVEL=DISABLED`\n\nRequirements:\n\n* Python 3.10+\n\nInstall:\n\n.. code-block:: bash\n\n   pip install belogging\n\n\nExamples:\n---------\n\nSimple applications:\n~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    # my_script.py\n\n    import belogging\n    belogging.load()\n    # ^^ this call is optional, only useful for customization\n    # For example, to enable JSON output: belogging.load(json=True)\n\n    # belogging.getLogger is just a sugar to logging.getLogger, you can\n    # use logging.getLogger as usual (and recommended).\n    logger = belogging.getLogger('foobar')\n    logger.debug('test 1')\n    logger.info('test 2')\n\n\nExecuting:\n\n.. code-block:: bash\n\n    # selecting LOG_LEVEL\n    $ LOG_LEVEL=DEBUG python my_script.py\n    # level=DEBUG message=test 1\n    # level=INFO message=test 2\n\n    # selecting LOGGERS\n    $ LOGGERS=foobar python my_script.py\n    # Both messages\n\n    # Both\n    $ LOGGERS=foobar LOG_LEVEL=INFO my_script.py\n    # only level=INFO message=test 2\n\n\nApplications should call ```belogging.load()``` upon initialization.\nThe first ```__init__.py``` would be a good candidate, but anything before any call to\n```logging``` module will be fine.\n\n\nDjango:\n~~~~~~~\n\n\nIn your projects ```settings.py```:\n\n.. code-block:: python\n\n    import belogging\n    # Disable django logging setup\n    LOGGING_CONFIG = None\n    belogging.load()\n\n\nInside your code, just use ```logging.getLogger()``` as usual.\n\n.. code-block:: bash\n\n    $ export LOG_LEVEL=WARNING\n    $ ./manage.py runserver\n    # It will output only logging messages with severity > WARNING\n\n\nLogging follows a hierarchy, so you easily select or skip some logging messages:\n\n\n.. code-block:: bash\n\n    $ export LOGGERS=my_app.critical_a,my_app.critical_c,my_lib\n    $ ./my-app.py\n    # \"my_app.critical_b messages\" will be skipped\n    # all messages from my_lib will show up\n\n\n.. |Coverage Status| image:: https://coveralls.io/repos/github/georgeyk/belogging/badge.svg?branch=master\n   :target: https://coveralls.io/github/georgeyk/belogging?branch=master\n.. |PyPI Version| image:: https://img.shields.io/pypi/pyversions/belogging.svg?maxAge=2592000\n   :target: https://pypi.python.org/pypi/belogging\n.. |PyPI License| image:: https://img.shields.io/pypi/l/belogging.svg?maxAge=2592000\n   :target: https://pypi.python.org/pypi/belogging\n.. |PyPI latest| image:: https://img.shields.io/pypi/v/belogging.svg?maxAge=2592000\n   :target: https://pypi.python.org/pypi/belogging\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2016 George Kussumoto  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Easy and opinionated logging configuration for Python apps",
    "version": "0.2.0",
    "project_urls": {
        "Github": "https://github.com/georgeyk/belogging/",
        "Releases": "https://github.com/georgeyk/belogging/releases"
    },
    "split_keywords": [
        "logging"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "631688dbc386ea75fb33ec0d46d3c84f23c1a6884a159876cb29361d148cf66d",
                "md5": "76e0e1da6f66ba3aa1ee24caa6bab2e1",
                "sha256": "fb9aeb583274d9354ed646ae7c6e82c4a206470021c895382849c3a34ae78610"
            },
            "downloads": -1,
            "filename": "belogging-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "76e0e1da6f66ba3aa1ee24caa6bab2e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 6730,
            "upload_time": "2024-12-18T20:00:13",
            "upload_time_iso_8601": "2024-12-18T20:00:13.118949Z",
            "url": "https://files.pythonhosted.org/packages/63/16/88dbc386ea75fb33ec0d46d3c84f23c1a6884a159876cb29361d148cf66d/belogging-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4d64e0a91b7d8a9fafcdf795b7c1e909e4e2d3839d253aed5da69fb0eda64f01",
                "md5": "954d9eff409c494f2b56856fec819d21",
                "sha256": "fe28c51eef09e62acfd2139f8d249853198022c027e36b958f6bb59ac3da8987"
            },
            "downloads": -1,
            "filename": "belogging-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "954d9eff409c494f2b56856fec819d21",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 27265,
            "upload_time": "2024-12-18T20:00:14",
            "upload_time_iso_8601": "2024-12-18T20:00:14.709271Z",
            "url": "https://files.pythonhosted.org/packages/4d/64/e0a91b7d8a9fafcdf795b7c1e909e4e2d3839d253aed5da69fb0eda64f01/belogging-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-18 20:00:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "georgeyk",
    "github_project": "belogging",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "belogging"
}
        
Elapsed time: 0.56846s