Skip to main content

Configure Logging Easily

Project description

cfglog: Configurate Logging Easily

cfglog provides an easy way to setup logging. It supports the configuration of datetime in the logging system, which is useful when you want to share the time spent on the program's execution without revealing when the program was run.

Installation

pip install --upgrade cfglog

Usage Example

>>> import datetime as dt
>>> import logging
>>> import sys
>>> import cfglog
>>> cfglog.basicConfig(
...     level=logging.DEBUG,  # logging when level >= DEBUG
...     format="%(asctime)s [%(levelname)s] %(message)s",
...     datefmt="%H:%M:%S",
...     datetime=dt.datetime(2000, 1, 1),  # set current datetime in logging system as 2000-01-01T00:00:00
...     stream=sys.stdout,  # write to stdout rather than stderr
...     force=True,  # overwrite existing configuration
... )
>>> logging.debug("This is a debug message.")
00:00:00 [DEBUG] This is a debug message.
>>> logging.info("This is an info message.")
00:00:00 [INFO] This is an info message.
>>> logging.warning("This is a warning message.")
00:00:00 [WARNING] This is a warning message.
>>> logging.error("This is an error message.")
00:00:00 [ERROR] This is an error message.
>>> logging.critical("This is a critical message.")
00:00:00 [CRITICAL] This is a critical message.

APIs

class TimeoffsetFormatter: An extended version of logging.Formatter that supports datetime configuration via the parameter datetime.

Function basicConfig(): An extended version of logging.basicConfig() that supports datetime configuration via the parameter datetime, and some features in newer/future version of Python such as style, handlers, force, encoding, and errors.

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

cfglog-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfglog-1.0.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file cfglog-1.0.0.tar.gz.

File metadata

  • Download URL: cfglog-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cfglog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e8245f7e12e64e75225f0aa76f2b6170e18a9272d5c27785215ee3c2b2a88a96
MD5 3840bdefb85ddeb556cada0801427c8f
BLAKE2b-256 8c8db12e0d5359255579c3f641aa1a81e9a001200a701442d4db89a3a4d2231f

See more details on using hashes here.

File details

Details for the file cfglog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cfglog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cfglog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b20266148f1c6a7a14c0a1ed812a6909b6f15457668806728657996f7b730059
MD5 8a279b0cf25cb718d2fa2e2aceb5b690
BLAKE2b-256 a1b111c4ab9a57cd5b3d9ae58a095802258369c1cb1de229334e8b3f148f8255

See more details on using hashes here.

Supported by

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