linz-logger


Namelinz-logger JSON
Version 0.11.0 PyPI version JSON
download
home_pagehttps://github.com/linz/python-linz-logger
SummaryLINZ standard Logging format
upload_time2022-12-05 23:30:00
maintainer
docs_urlNone
authorBlayne
requires_python>=3.8,<4.0
licenseMIT
keywords linz logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python LINZ Logger

[![GitHub Actions Status](https://github.com/linz/python-linz-logger/workflows/Build/badge.svg)](https://github.com/linz/python-linz-logger/actions)
[![Kodiak](https://badgen.net/badge/Kodiak/enabled?labelColor=2e3a44&color=F39938)](https://kodiakhq.com/)
[![Dependabot Status](https://badgen.net/badge/Dependabot/enabled?labelColor=2e3a44&color=blue)](https://github.com/linz/python-linz-logger/network/updates)
[![License](https://badgen.net/github/license/linz/python-linz-logger?labelColor=2e3a44&label=License)](https://github.com/linz/python-linz-logger/blob/master/LICENSE)
[![Conventional Commits](https://badgen.net/badge/Commits/conventional?labelColor=2e3a44&color=EC5772)](https://conventionalcommits.org)
[![Code Style](https://badgen.net/badge/Code%20Style/black?labelColor=2e3a44&color=000000)](https://github.com/psf/black)

## Why?

LINZ has a standard logging format based loosely on the [pinojs](https://github.com/pinojs/pino) logging format:

```json
{
  "level": 30,
  "time": 1571696532994,
  "pid": 10671,
  "hostname": "Ubuntu1",
  "id": "01DQR6KQG0K60TP4T1C4VC5P74",
  "msg": "SomeMessage",
  "v": 1
}
```

## Usage

```
pip install --upgrade linz-logger
```

```python
from os import environ

from linz_logger import get_log, set_level, LogLevel

set_level(LogLevel[environ.get("LOGLEVEL", "WARNING").lower()].value)
set_contextvars({"country": "NZ"}) # remove_contextvars(["country"]) to remove a key
get_log().error('Hello World', key="value")
# {"key": "value", "level": 50, "time": 1601555605017, "v": 1, "pid": 311800, "id": "01G9XAA1MCMX2K9NZN9GJJHN71", "msg": "Hello World", "hostname": "Ubuntu1", "country": "NZ"}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/linz/python-linz-logger",
    "name": "linz-logger",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "LINZ,logging",
    "author": "Blayne",
    "author_email": "bchard@linz.govt.nz",
    "download_url": "https://files.pythonhosted.org/packages/71/29/de1a703fae473d8014d1770e86e7f6b46b9b02dbe84ea6c2dc4bf1476902/linz_logger-0.11.0.tar.gz",
    "platform": null,
    "description": "# Python LINZ Logger\n\n[![GitHub Actions Status](https://github.com/linz/python-linz-logger/workflows/Build/badge.svg)](https://github.com/linz/python-linz-logger/actions)\n[![Kodiak](https://badgen.net/badge/Kodiak/enabled?labelColor=2e3a44&color=F39938)](https://kodiakhq.com/)\n[![Dependabot Status](https://badgen.net/badge/Dependabot/enabled?labelColor=2e3a44&color=blue)](https://github.com/linz/python-linz-logger/network/updates)\n[![License](https://badgen.net/github/license/linz/python-linz-logger?labelColor=2e3a44&label=License)](https://github.com/linz/python-linz-logger/blob/master/LICENSE)\n[![Conventional Commits](https://badgen.net/badge/Commits/conventional?labelColor=2e3a44&color=EC5772)](https://conventionalcommits.org)\n[![Code Style](https://badgen.net/badge/Code%20Style/black?labelColor=2e3a44&color=000000)](https://github.com/psf/black)\n\n## Why?\n\nLINZ has a standard logging format based loosely on the [pinojs](https://github.com/pinojs/pino) logging format:\n\n```json\n{\n  \"level\": 30,\n  \"time\": 1571696532994,\n  \"pid\": 10671,\n  \"hostname\": \"Ubuntu1\",\n  \"id\": \"01DQR6KQG0K60TP4T1C4VC5P74\",\n  \"msg\": \"SomeMessage\",\n  \"v\": 1\n}\n```\n\n## Usage\n\n```\npip install --upgrade linz-logger\n```\n\n```python\nfrom os import environ\n\nfrom linz_logger import get_log, set_level, LogLevel\n\nset_level(LogLevel[environ.get(\"LOGLEVEL\", \"WARNING\").lower()].value)\nset_contextvars({\"country\": \"NZ\"}) # remove_contextvars([\"country\"]) to remove a key\nget_log().error('Hello World', key=\"value\")\n# {\"key\": \"value\", \"level\": 50, \"time\": 1601555605017, \"v\": 1, \"pid\": 311800, \"id\": \"01G9XAA1MCMX2K9NZN9GJJHN71\", \"msg\": \"Hello World\", \"hostname\": \"Ubuntu1\", \"country\": \"NZ\"}\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "LINZ standard Logging format",
    "version": "0.11.0",
    "split_keywords": [
        "linz",
        "logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "26ef8015917ffe26226ef591628df9b5",
                "sha256": "1e8ef3f85a77e9506728a022e7b9b6b835c32a7d784ee8d78b6bb28755cc264a"
            },
            "downloads": -1,
            "filename": "linz_logger-0.11.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26ef8015917ffe26226ef591628df9b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 4798,
            "upload_time": "2022-12-05T23:29:59",
            "upload_time_iso_8601": "2022-12-05T23:29:59.669922Z",
            "url": "https://files.pythonhosted.org/packages/7a/b5/310ff8b62f7607d8b127ebe222acfc1394aca0b5f490832903b70672fa7e/linz_logger-0.11.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "2f84589ee71bd6d5620b2dc4a4736031",
                "sha256": "7454e18f613b5aafbb38cad1478d48eab15bacd4d3fe8bb70fcc55f4ea139a6b"
            },
            "downloads": -1,
            "filename": "linz_logger-0.11.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2f84589ee71bd6d5620b2dc4a4736031",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 4368,
            "upload_time": "2022-12-05T23:30:00",
            "upload_time_iso_8601": "2022-12-05T23:30:00.917716Z",
            "url": "https://files.pythonhosted.org/packages/71/29/de1a703fae473d8014d1770e86e7f6b46b9b02dbe84ea6c2dc4bf1476902/linz_logger-0.11.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-05 23:30:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "linz",
    "github_project": "python-linz-logger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "linz-logger"
}
        
Elapsed time: 0.20333s