vmodule


Namevmodule JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/python-packaging/vmodule/
SummaryEnable glog-style vmodule for python's logging
upload_time2024-02-26 18:13:08
maintainer
docs_urlNone
authorTim Hatch
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # vmodule

This is a tiny project with no deps to add extra levels to stdlib logging, and
also something you can run from your main that processes logger-specific
verbosity.

This is inspired by glog, which considers VLOG(1) to be a more restrictive
version of LOG(INFO).  For simplicity we just map that onto numeric severities.

Here's a combined demo of how you might use this library -- we don't depend on
`click` but you certainly can:

```py
from logging import getLogger
from typing import Optional

import click

from vmodule import VLOG_1, VLOG_2, vmodule_init

LOG = getLogger(__name__)


@click.command()
@click.option("-v", type=int)
@click.option("--vmodule")
def main(v: Optional[int], vmodule: Optional[str]) -> None:
    vmodule_init(v, vmodule)
    LOG.warning("Warn")
    LOG.info("Starting up")
    LOG.log(VLOG_1, "Verbose %d", 1)
    LOG.log(VLOG_2, "Verbose %d", 2)
    LOG.debug("foo")


if __name__ == "__main__":
    main()
```

If you're writing a library, it's even easier:

```py
from logging import getLogger
from vmodule import VLOG_1

LOG = getLogger(__name__)

def foo(...):
    LOG.info("Starting up")
    LOG.log(VLOG_1, "Verbose %d", 1)
```


# Command line parsing

If you use the example above,

```
(unset)  -> WARNING
-v 0     -> INFO
-v 1     -> VLOG_1
-v 2     -> VLOG_2
-v 3     -> VLOG_3
-v 10    -> DEBUG (by accident)
```

You can also specify those same numbers with `--vmodule` although there are two
gotchas:

1. You CLI's logger is quite possibly called `"__main__"`.
2. This doesn't take wildcards or use hierarchy.  You need to specify actual
   logger names.


```
--vmodule filelock=10,concurrent.futures=0

sets filelock to DEBUG
sets concurrent.futures to INFO
```

# Version Compat

Usage of this library should work back to 3.7, but development (and mypy
compatibility) only on 3.10-3.12.  Linting requires 3.12 for full fidelity.

# License

vmodule is copyright [Tim Hatch](https://timhatch.com/), and licensed under
the MIT license.  I am providing code in this repository to you under an open
source license.  This is my personal repository; the license you receive to
my code is from me and not from my employer. See the `LICENSE` file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/python-packaging/vmodule/",
    "name": "vmodule",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tim Hatch",
    "author_email": "tim@timhatch.com",
    "download_url": "https://files.pythonhosted.org/packages/7b/84/40325a220dd817b019362f3c5bf71975e4418599c688b76ee7102d13e2fc/vmodule-0.5.0.tar.gz",
    "platform": null,
    "description": "# vmodule\n\nThis is a tiny project with no deps to add extra levels to stdlib logging, and\nalso something you can run from your main that processes logger-specific\nverbosity.\n\nThis is inspired by glog, which considers VLOG(1) to be a more restrictive\nversion of LOG(INFO).  For simplicity we just map that onto numeric severities.\n\nHere's a combined demo of how you might use this library -- we don't depend on\n`click` but you certainly can:\n\n```py\nfrom logging import getLogger\nfrom typing import Optional\n\nimport click\n\nfrom vmodule import VLOG_1, VLOG_2, vmodule_init\n\nLOG = getLogger(__name__)\n\n\n@click.command()\n@click.option(\"-v\", type=int)\n@click.option(\"--vmodule\")\ndef main(v: Optional[int], vmodule: Optional[str]) -> None:\n    vmodule_init(v, vmodule)\n    LOG.warning(\"Warn\")\n    LOG.info(\"Starting up\")\n    LOG.log(VLOG_1, \"Verbose %d\", 1)\n    LOG.log(VLOG_2, \"Verbose %d\", 2)\n    LOG.debug(\"foo\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\nIf you're writing a library, it's even easier:\n\n```py\nfrom logging import getLogger\nfrom vmodule import VLOG_1\n\nLOG = getLogger(__name__)\n\ndef foo(...):\n    LOG.info(\"Starting up\")\n    LOG.log(VLOG_1, \"Verbose %d\", 1)\n```\n\n\n# Command line parsing\n\nIf you use the example above,\n\n```\n(unset)  -> WARNING\n-v 0     -> INFO\n-v 1     -> VLOG_1\n-v 2     -> VLOG_2\n-v 3     -> VLOG_3\n-v 10    -> DEBUG (by accident)\n```\n\nYou can also specify those same numbers with `--vmodule` although there are two\ngotchas:\n\n1. You CLI's logger is quite possibly called `\"__main__\"`.\n2. This doesn't take wildcards or use hierarchy.  You need to specify actual\n   logger names.\n\n\n```\n--vmodule filelock=10,concurrent.futures=0\n\nsets filelock to DEBUG\nsets concurrent.futures to INFO\n```\n\n# Version Compat\n\nUsage of this library should work back to 3.7, but development (and mypy\ncompatibility) only on 3.10-3.12.  Linting requires 3.12 for full fidelity.\n\n# License\n\nvmodule is copyright [Tim Hatch](https://timhatch.com/), and licensed under\nthe MIT license.  I am providing code in this repository to you under an open\nsource license.  This is my personal repository; the license you receive to\nmy code is from me and not from my employer. See the `LICENSE` file for details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Enable glog-style vmodule for python's logging",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/python-packaging/vmodule/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e69e984f70400b31b642aa632737da544237230b238b81e5ad9c55b177faf38",
                "md5": "c00be9bde913c6135afce8f4ebcf7705",
                "sha256": "34b4c1f4f53bb16b95c0986740949ec0caf0732e0d3ed16f8563867b0b3d3b47"
            },
            "downloads": -1,
            "filename": "vmodule-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c00be9bde913c6135afce8f4ebcf7705",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5717,
            "upload_time": "2024-02-26T18:13:06",
            "upload_time_iso_8601": "2024-02-26T18:13:06.255231Z",
            "url": "https://files.pythonhosted.org/packages/4e/69/e984f70400b31b642aa632737da544237230b238b81e5ad9c55b177faf38/vmodule-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7b8440325a220dd817b019362f3c5bf71975e4418599c688b76ee7102d13e2fc",
                "md5": "9fd81e2d15e8336d2186dc060427b07a",
                "sha256": "1d3c34d20ccfef5525d2fde0b2b40d7e19027e761ba2bff48afa9f390e0856ce"
            },
            "downloads": -1,
            "filename": "vmodule-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9fd81e2d15e8336d2186dc060427b07a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7041,
            "upload_time": "2024-02-26T18:13:08",
            "upload_time_iso_8601": "2024-02-26T18:13:08.824357Z",
            "url": "https://files.pythonhosted.org/packages/7b/84/40325a220dd817b019362f3c5bf71975e4418599c688b76ee7102d13e2fc/vmodule-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 18:13:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "python-packaging",
    "github_project": "vmodule",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "vmodule"
}
        
Elapsed time: 0.34257s