Skip to main content

This is powerful logging

Project description

PColorLogging

The powerful python logging, you can create colorful logging and easy to add logging level or record attribute

Getting Start

To create the logger

import logging

from PColorLogging import DEBUG, INFO, ERROR, WARNING, CRITICAL
from PColorLogging.Drawer.color import PColor, TextMode
from PColorLogging.Formatter.colored_formatter import ColoredFormatter
from PColorLogging.Logger.Adapter.extra_adapter_logger import ExtraAdapterLogger

colored_formatter = ColoredFormatter(f"[%(asctime)s] %(levelname)s:%(phuc)s %(message)s", [
    {"config": {"message": [PColor.BLUE]}, "level": [DEBUG]},
    {"config": {"message": [PColor.BLUE, TextMode.CROSS], "phuc": [PColor.B_WHITE]}, "level": [INFO]},
    {"config": {"message": [PColor.CYAN, TextMode.UNDERLINE]}, "level": [ERROR]},
    {"config": {"message": [PColor.GREEN, TextMode.SLOW_BLINK]}, "level": [WARNING]},
    {"config": {"message": [PColor.WHITE, TextMode.FAST_BLINK]}, "level": [CRITICAL]},
    {"config": {"message": [PColor.BLUE], "levelname": [PColor.B_CYAN, PColor.WHITE]}, "level": [25]}
])

extra_logger = ExtraAdapterLogger("logger", {"phuc": ""})

console_handler = logging.StreamHandler()
console_handler.setFormatter(colored_formatter)
extra_logger.add_handler(console_handler)
extra_logger.setLevel(logging.INFO)

extra_logger.debug("this is debug", extra={"phuc": 4321})
extra_logger.info("this is info")
extra_logger.warning("this is warning")
extra_logger.error("this is error")
extra_logger.critical("this is critical")
extra_logger.log(25, "this is custom logging level")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PColorLogging-0.0.21.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

PColorLogging-0.0.21-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file PColorLogging-0.0.21.tar.gz.

File metadata

  • Download URL: PColorLogging-0.0.21.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for PColorLogging-0.0.21.tar.gz
Algorithm Hash digest
SHA256 1c2de393083a3d54c05bcb4d08c77b50e2f4fbb32909c6ebc0a6031820fe2e6d
MD5 5f2809b6542119370f0d7c8e24c931d8
BLAKE2b-256 89bf54bf628d65786b9f1cb95e30708224b34451624b81c5af0a894ae7957737

See more details on using hashes here.

File details

Details for the file PColorLogging-0.0.21-py3-none-any.whl.

File metadata

  • Download URL: PColorLogging-0.0.21-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for PColorLogging-0.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 a9a73c82295c1a270df4103d3d99369e55027509b012f0d4662ebdb1b6b724a3
MD5 792b0a56848c9f2df8d26fadeaebaf59
BLAKE2b-256 abe0f1f93b7d79511864d3b8f5e958ab712cdc80825134698a9e1da6384f0d9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page