Name | viperlog JSON |
Version |
0.2.59
JSON |
| download |
home_page | None |
Summary | ViperLog core logging package |
upload_time | 2025-09-16 14:43:52 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# VIPERLOG
This library is build on top of the python logging,
it's not meant to replace it but rather make it easier to configure
and work together with it.
This means that you can still use the build-in python getLogger for logging and no code changes are required apart from configuring this library.
## Installation
Some of the processors like console and http have additional dependencies
and are optionally installed.
pip install viperlog[all] # everything
pip install viperlog[core] # The minimal core module which allows logging to file
pip install viperlog[console] # console module
pip install viperlog[http] # http module
pip install viperlog[console,http] # http+console modules
## Usage
Get an instance of the Viperlog singleton class
# both viperlog.logger.getLogger and logging.getLogger work the same
import logging
from viperlog import Viperlog, setup_viperlog_handler
from viperlog.processors.console import ConsoleProcessor
from viperlog.processors import FileProcessor
from viperlog.formatters import JsonObjectFormatter
# get a logger (normally this is the root logger, but you can attach the handlers any logger)
logger = logging.getLogger()
handler = setup_viperlog_handler("core-handler",
logger=logger,
min_level=logging.DEBUG,
flush_level=logging.ERROR,
processors=[
ConsoleProcessor(
template="MyLog: ${datetime} ${level|upper} ${message}"
),
FileProcessor(file="/var/log/mylog.txt"),
FileProcessor(
file="/var/log/mylog.json",
formatter=JsonObjectFormatter(
template="MyLog: ${datetime} ${level|upper} ${message}"
)
)
],
filters=[ PackageFilter({"my.namespace":logging.INFO}) ]
)
# you can attach the handler to more loggers if you need to
handler.attach_to(...)
# or remove it from all loggers it is attached to
handler.detach_all()
So what does the setup_handler do?
It attaches a handler to the specified logger to process the messages.
- min_level: The minimum log level needed for messages to be processed
- flush_level: Records are processed in batches, if a message with this level comes in the buffer is flushed immediately. (So setting it to DEBUG or NOTSET effectively disables the buffer, alternatively if supports_batching = False in the IProcessor then the records will also be processed immediately)
- filters: Optional filters (viperlog.filters.IFilter protocol) to accept/reject messages based on the configuration. The PackageFilter in the example allows you to configure minimum log levels for namespaces without modifying the underlying logger instances. This can be useful if you would want different loglevels for different processors.
- processors: These instances of viperlog.processors.IProcessor take the messages, format and transport them to somewhere. The ConsoleProcessor will output to the console, the FileProcessor to a file etc.
Most of the processors will accept a viperlog.formatters.IFormatter or a template string that will be used to format the log message
You can call the setup_handler multiple times with different settings. In the above example the Console & File processors are combined,
but you could setup separate handlers for them with different settings.
Raw data
{
"_id": null,
"home_page": null,
"name": "viperlog",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/5d/a7/7e9ad1e6c29b03c7e022a7d30e4c58fd47824de950241fc7236439807aec/viperlog-0.2.59.tar.gz",
"platform": null,
"description": "# VIPERLOG\n\nThis library is build on top of the python logging, \nit's not meant to replace it but rather make it easier to configure\nand work together with it. \n\nThis means that you can still use the build-in python getLogger for logging and no code changes are required apart from configuring this library.\n\n## Installation\nSome of the processors like console and http have additional dependencies\nand are optionally installed. \n\n pip install viperlog[all] # everything\n pip install viperlog[core] # The minimal core module which allows logging to file\n pip install viperlog[console] # console module\n pip install viperlog[http] # http module\n pip install viperlog[console,http] # http+console modules\n\n\n\n\n## Usage\n\nGet an instance of the Viperlog singleton class\n \n # both viperlog.logger.getLogger and logging.getLogger work the same\n import logging\n from viperlog import Viperlog, setup_viperlog_handler\n from viperlog.processors.console import ConsoleProcessor\n from viperlog.processors import FileProcessor\n from viperlog.formatters import JsonObjectFormatter\n \n # get a logger (normally this is the root logger, but you can attach the handlers any logger)\n logger = logging.getLogger()\n \n handler = setup_viperlog_handler(\"core-handler\", \n logger=logger, \n min_level=logging.DEBUG, \n flush_level=logging.ERROR, \n processors=[\n ConsoleProcessor(\n template=\"MyLog: ${datetime} ${level|upper} ${message}\"\n ),\n FileProcessor(file=\"/var/log/mylog.txt\"),\n FileProcessor(\n file=\"/var/log/mylog.json\",\n formatter=JsonObjectFormatter(\n template=\"MyLog: ${datetime} ${level|upper} ${message}\"\n )\n )\n ], \n filters=[ PackageFilter({\"my.namespace\":logging.INFO}) ]\n )\n \n # you can attach the handler to more loggers if you need to\n handler.attach_to(...)\n # or remove it from all loggers it is attached to\n handler.detach_all()\nSo what does the setup_handler do?\nIt attaches a handler to the specified logger to process the messages.\n- min_level: The minimum log level needed for messages to be processed\n- flush_level: Records are processed in batches, if a message with this level comes in the buffer is flushed immediately. (So setting it to DEBUG or NOTSET effectively disables the buffer, alternatively if supports_batching = False in the IProcessor then the records will also be processed immediately)\n- filters: Optional filters (viperlog.filters.IFilter protocol) to accept/reject messages based on the configuration. The PackageFilter in the example allows you to configure minimum log levels for namespaces without modifying the underlying logger instances. This can be useful if you would want different loglevels for different processors.\n- processors: These instances of viperlog.processors.IProcessor take the messages, format and transport them to somewhere. The ConsoleProcessor will output to the console, the FileProcessor to a file etc. \n\nMost of the processors will accept a viperlog.formatters.IFormatter or a template string that will be used to format the log message \n\n\nYou can call the setup_handler multiple times with different settings. In the above example the Console & File processors are combined, \nbut you could setup separate handlers for them with different settings.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "ViperLog core logging package",
"version": "0.2.59",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "43c9b53f622df166a299c21c711d373ee01d0c46d59a531a4bbd9b241fdb935a",
"md5": "e2438a6affb6a34f939c9bf5379f0ba6",
"sha256": "af53ef605519951fc2b6541f4eab10567b8690e677015f88ad6cb420bdbf3654"
},
"downloads": -1,
"filename": "viperlog-0.2.59-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e2438a6affb6a34f939c9bf5379f0ba6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 21709,
"upload_time": "2025-09-16T14:43:51",
"upload_time_iso_8601": "2025-09-16T14:43:51.711301Z",
"url": "https://files.pythonhosted.org/packages/43/c9/b53f622df166a299c21c711d373ee01d0c46d59a531a4bbd9b241fdb935a/viperlog-0.2.59-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5da77e9ad1e6c29b03c7e022a7d30e4c58fd47824de950241fc7236439807aec",
"md5": "4856b313db2f10dcbc6e1f45d9b1357c",
"sha256": "1aba3dc2da1026fe9e3daf83c92dc5c2eafb69cc9ab7169cc77219113a3db850"
},
"downloads": -1,
"filename": "viperlog-0.2.59.tar.gz",
"has_sig": false,
"md5_digest": "4856b313db2f10dcbc6e1f45d9b1357c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 15855,
"upload_time": "2025-09-16T14:43:52",
"upload_time_iso_8601": "2025-09-16T14:43:52.675415Z",
"url": "https://files.pythonhosted.org/packages/5d/a7/7e9ad1e6c29b03c7e022a7d30e4c58fd47824de950241fc7236439807aec/viperlog-0.2.59.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-16 14:43:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "viperlog"
}