| Name | humiologging JSON |
| Version |
1.0.4
JSON |
| download |
| home_page | |
| Summary | Log utilities for Humio: Handlers, formatters |
| upload_time | 2023-08-11 07:31:29 |
| maintainer | |
| docs_url | None |
| author | |
| requires_python | >=3.7 |
| license | |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
================
Logging to Humio
================
.. image:: https://github.com/Uninett/python-logging-humio/actions/workflows/ci.yml/badge.svg
:target: https://github.com/Uninett/python-logging-humio/actions/workflows/ci.yml
:alt: CI Status
.. image:: https://img.shields.io/pypi/v/humiologging
:target: https://pypi.org/project/humiologging/
:alt: PyPI: humiologging
.. image:: https://img.shields.io/pypi/pyversions/humiologging
:alt: Python versions: 3.6, 3.7, 3.8, 3.9
.. image:: https://img.shields.io/pypi/l/humiologging
:alt: License: Apache 2.0
This package contains logging handlers and formatters useful for logging
to `Humio <https://www.humio.com/>`_. It's sole runtime dependency is
`humiolib <https://github.com/humio/python-humio>`_.
Runs and tested on Python 3.6, 3.7, 3.8, 3.9.
Contents
========
Installation
------------
The pacakage on PyPI is named ``humiologging``, same as the package name.
Install with for instance ``pip install humiologging``.
Formatters
----------
``humiologging.formatters.HumioKVFormatter``
Turns every attribute on the log record into a key-value pair, as suitable
for the Humio "kv"-parser. Use with ``HumioHandler``.
``humiologging.formatters.HumioJSONFormatter``
Turns the log-record into a json object, as suitable for the Humio
"json"-parser. Used by ``HumioJSONHandler``.
Handlers
--------
``humiologging.handlers.HumioHandler``
Sends line-based text log messages to Humio. You need to use a formatter
that Humio can parse, like ``HumioKVFormatter``.
``humiologging.handlers.HumioJSONHandler``
Sends json-formatted log messages to Humio. Does not need a formatter.
Positional arguments:
:humio_host: The url of the humio ingest host
:ingest_token: The API token for a Humio repo
Keyword arguments:
:level: A log-level
:tags: A dictionary of key value items that will be addded to each record
:add_host_tag:
Whether to automatically add the hostname/ip-address where
the loghandler is used as a tag
Be careful with setting many tags, see
`Humio Documentation: Tagging <https://docs.humio.com/docs/parsers/tagging/>`_
Testing
=======
Run automated tests with `tox <https://tox.readthedocs.io/en/latest/>`_.
To test against humio: you need the hostname of the humio instance and an
ingest_token for a repo with parser set to the handler you want to test.
With no parser set
------------------
import logging
logging.basicConfig(handlers=[HumioJSONHandler(host, token)])
logging.error('This is a test')
In Humio you should get a single entry with one key for every attribute in the
log record. One additional key `formattedMessage` contains the human-readable
format set in the logging config as a string.
For parser ``kv``
-----------------
import logging
logging.basicConfig(handlers=[HumioHandler(host, token).setFormatter(HumioKVFormatter())])
logging.error('This is a test')
In Humio you should get a single record with a string containing many key=value
pairs. One additional key `formattedMessage` contains the human-readable
format set in the logging config as a string.
Raw data
{
"_id": null,
"home_page": "",
"name": "humiologging",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Uninett Opensource <opensource@uninett.no>",
"download_url": "",
"platform": null,
"description": "================\nLogging to Humio\n================\n\n.. image:: https://github.com/Uninett/python-logging-humio/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/Uninett/python-logging-humio/actions/workflows/ci.yml\n :alt: CI Status\n\n.. image:: https://img.shields.io/pypi/v/humiologging\n :target: https://pypi.org/project/humiologging/\n :alt: PyPI: humiologging\n\n.. image:: https://img.shields.io/pypi/pyversions/humiologging\n :alt: Python versions: 3.6, 3.7, 3.8, 3.9\n\n.. image:: https://img.shields.io/pypi/l/humiologging\n :alt: License: Apache 2.0\n\nThis package contains logging handlers and formatters useful for logging\nto `Humio <https://www.humio.com/>`_. It's sole runtime dependency is\n`humiolib <https://github.com/humio/python-humio>`_.\n\nRuns and tested on Python 3.6, 3.7, 3.8, 3.9.\n\nContents\n========\n\nInstallation\n------------\n\nThe pacakage on PyPI is named ``humiologging``, same as the package name.\nInstall with for instance ``pip install humiologging``.\n\nFormatters\n----------\n\n``humiologging.formatters.HumioKVFormatter``\n Turns every attribute on the log record into a key-value pair, as suitable\n for the Humio \"kv\"-parser. Use with ``HumioHandler``.\n\n``humiologging.formatters.HumioJSONFormatter``\n Turns the log-record into a json object, as suitable for the Humio\n \"json\"-parser. Used by ``HumioJSONHandler``.\n\nHandlers\n--------\n\n``humiologging.handlers.HumioHandler``\n Sends line-based text log messages to Humio. You need to use a formatter\n that Humio can parse, like ``HumioKVFormatter``.\n\n``humiologging.handlers.HumioJSONHandler``\n Sends json-formatted log messages to Humio. Does not need a formatter.\n\nPositional arguments:\n\n :humio_host: The url of the humio ingest host\n :ingest_token: The API token for a Humio repo\n\nKeyword arguments:\n\n :level: A log-level\n :tags: A dictionary of key value items that will be addded to each record\n :add_host_tag:\n Whether to automatically add the hostname/ip-address where\n the loghandler is used as a tag\n\nBe careful with setting many tags, see\n`Humio Documentation: Tagging <https://docs.humio.com/docs/parsers/tagging/>`_\n\nTesting\n=======\n\nRun automated tests with `tox <https://tox.readthedocs.io/en/latest/>`_.\n\nTo test against humio: you need the hostname of the humio instance and an\ningest_token for a repo with parser set to the handler you want to test.\n\nWith no parser set\n------------------\n\n import logging\n logging.basicConfig(handlers=[HumioJSONHandler(host, token)])\n logging.error('This is a test')\n\nIn Humio you should get a single entry with one key for every attribute in the\nlog record. One additional key `formattedMessage` contains the human-readable\nformat set in the logging config as a string.\n\nFor parser ``kv``\n-----------------\n\n import logging\n logging.basicConfig(handlers=[HumioHandler(host, token).setFormatter(HumioKVFormatter())])\n logging.error('This is a test')\n\nIn Humio you should get a single record with a string containing many key=value\npairs. One additional key `formattedMessage` contains the human-readable\nformat set in the logging config as a string.\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Log utilities for Humio: Handlers, formatters",
"version": "1.0.4",
"project_urls": {
"Homepage": "https://github.com/Uninett/python-logging-humio"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "17adafab9fb8a6ea9e033260b4a7b87107d3e1b37d2df86f183614fe921e78cd",
"md5": "2bac15a6919c7f950ff795903f7d4e32",
"sha256": "dc23f4072840df6126695ba7b83f0296004d134e6613687af70258b9d14e9a5d"
},
"downloads": -1,
"filename": "humiologging-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2bac15a6919c7f950ff795903f7d4e32",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 9594,
"upload_time": "2023-08-11T07:31:29",
"upload_time_iso_8601": "2023-08-11T07:31:29.622613Z",
"url": "https://files.pythonhosted.org/packages/17/ad/afab9fb8a6ea9e033260b4a7b87107d3e1b37d2df86f183614fe921e78cd/humiologging-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-11 07:31:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Uninett",
"github_project": "python-logging-humio",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "humiologging"
}