Skip to main content

py-logging-fmt

python logging formatter. JSONFormatter、GenericFormatter、CeleryTaskFormatter

Installation

$ pip install pylogformatter

---> 100%

Example

Create it

  • Create a file example.py with:
import logging
from pylogformatter.json import JSONFormatter

logger = logging.getLogger()
logHandler = logging.StreamHandler()
formatter = JSONFormatter(hostname="app.example.com", indent=True)
logHandler.setFormatter(formatter)
logger.addHandler(logHandler)
logger.error('hello world!', extra={"tags": ["app=helloworld"]})

Out:

{
 "@timestamp": "2021-05-27 03:03:01.745983 +00:00",
 "app_host_name": "app.example.com",
 "logger_name": "root",
 "level": "ERROR",
 "pathname": ".\\example.py",
 "lineno": 17,
 "func_name": "<module>",
 "thread_id": 30612,
 "thread_name": "MainThread",
 "process_id": 7356,
 "process_name": "MainProcess",
 "message": "hello world!",
 "tags": [
  "app=helloworld"
 ]
}

Release files for pylogformatter 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylogformatter 0.0.1
File Size Uploaded
pylogformatter-0.0.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylogformatter 0.0.1
File Interpreter ABI Platform
pylogformatter-0.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.6 kB

Release files / pylogformatter-0.0.1.tar.gz

Download URL pylogformatter-0.0.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
81a76f230719e9b6285bf0cc3adfc900ae82ea58a9483928d1658f9bf31ddde4
BLAKE2b-256 checksum
How to use checksums
ccad9d12b0a7c1ab9d5e6e77ca8f7be49fa691213d5f977d3a3dcdc48b95d2d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.24.0

Release files / pylogformatter-0.0.1-py2.py3-none-any.whl

Download URL pylogformatter-0.0.1-py2.py3-none-any.whl
Size 6.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b2b5de570a08cfd2be9ab4d256d69c3ed39072ac5846ce057b3ebe145c518b18
BLAKE2b-256 checksum
How to use checksums
a2515306cdcce115376eb925793e9cfd78abd3c9e62c8f3d51b7d4783bf01b50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.24.0

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page