Skip to main content

PyLogFormats

PyPI Status Python Version License

Read the documentation at https://pylogformats.readthedocs.io/ Tests Codecov

pre-commit Black

Features

  • Json Formatters

    • AdvJsonFormat
    {
      "logger": "root",
      "timestamp": "2021-02-04T23:02:52.522958",
      "rtimestamp": "2021-02-04T23:02:37.518800",
      "message": "TEST",
      "level": "ERROR",
      "levelno": 40,
      "location": {
        "pathname": "<FULL_PATH>\\test_logger.py",
        "module": "test_logger",
        "filename": "test_logger.py",
        "function": "<module>",
        "line": 16
      },
      "process": {
        "number": 2300,
        "name": "MainProcess"
      },
      "thread": {
        "number": 12516,
        "name": "MainThread"
      },
      "v": 1
    }
    
    • BunyanFormat
    {
      "time": "2021-02-04T23:01:00.781Z",
      "name": "root",
      "pid": 15504,
      "level": 40,
      "msg": "TEST",
      "hostname": "HerculesPC",
      "v": 0
    }
    
    • JsonFormat
    {
      "logger": "root",
      "timestamp": "2021-02-04T23:01:46.435011",
      "message": "TEST",
      "level": "ERROR",
      "levelno": 40,
      "function": "<module>",
      "process": {
        "number": 13316,
        "name": "MainProcess"
      },
      "thread": {
        "number": 10704,
        "name": "MainThread"
      },
      "v": 1
    }
    
  • Text Formatters

    • SimpleTextFormat
    [DEBUG] [2021-02-04 23:01:46] A Test Debug Log
    
    • CompactTextFormat
    [D 2021-02-04 23:01:46 l:root f:<module> ln:5] A Test Log [includesExtras:Yes]
    

Installation

You can install PyLogFormats via pip from PyPI:

$ pip install pylogformats

Usage

For an explanation of this, and more usage instructions please visit the documentation

import logging
import sys

from pylogformats import JsonFormat

# Create the logging handler
handler = logging.StreamHandler(sys.stdout)

# Add the formatter class to the handler we just created.
handler.setFormatter(JsonFormat())

# Use basicConfig to setup the loggers.
logging.basicConfig(handlers=[handler], level=logging.DEBUG)

# Use the normal logging methods to see formatted logs in your terminal
logging.critical("Critical Log")
logging.error("Error Log")
logging.warning("Warning Log")
logging.info("Info Log")
logging.debug("Debug Log")

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, PyLogFormats is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Credits

This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.

Metadata

Release files for pylogformats 1.0.0

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

Source distribution (sdist)

Source distribution for pylogformats 1.0.0
File Size Uploaded Provenance Actions
pylogformats-1.0.0.tar.gz 9.1 kB Without provenance Details for pylogformats-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylogformats 1.0.0
File Interpreter ABI Platform Actions
pylogformats-1.0.0-py3-none-any.whl Python 3 none any Details for pylogformats-1.0.0-py3-none-any.whl

Total release size: 21.4 kB

Release files / pylogformats-1.0.0.tar.gz

Download URL pylogformats-1.0.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
118cc3e64b04f1011b790b1dbb0af3c0dfcc8f712ddfe161d1ce20886ec9e47a
BLAKE2b-256 checksum
How to use checksums
47465838b80ddffcfebbfa40e9f62a7fec37dd07a00618c5ebec607a946092aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.5 Windows/10

Release files / pylogformats-1.0.0-py3-none-any.whl

Download URL pylogformats-1.0.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d61921d7134f3ff079b8625f5d20332ad29482abbb2888f00fcfecdfa5a2d444
BLAKE2b-256 checksum
How to use checksums
9faf18314f04660dd8e872a94df3826d22891a34d5f409879f0295ea1a971cea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.5 Windows/10

Security for pylogformats 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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