Skip to main content

Configure 🎁 Your 🤗 Python 🐍 Logging 📝

Project description

Configure 🎁 Your 🤗 Python 🐍 Logging 📝

PyPI

Installation

pip install pydantic-loggings

Usage

out of the box

from pydantic_loggings.base import Logging


logger = Logging().get_logger(configure=True)

logger.debug('debug')
logger.info('info')
logger.warning('warning')

# 01-01 00:00:00 DEBUG   debug
# 01-01 00:00:00 INFO    info
# 01-01 00:00:00 WARNING warning

Default Logging

from pydantic_loggings.not_set import Logging


logger = Logging().get_logger(configure=True)

logger.debug('debug')
logger.info('info')
logger.warning('warning')

# warning

Configure from Environment

from pathlib import Path

from pydantic_loggings.not_set import Logging


env_file = Path(__file__).parent / '.env'
logger = Logging(_env_file=env_file).get_logger(configure=True)

logger.debug('debug')
logger.info('info')
logger.warning('warning')

# 01-01 00:00:00 [root]   DEBUG (main.py:11) debug
# 01-01 00:00:00 [root]    INFO (main.py:12) info
# 01-01 00:00:00 [root] WARNING (main.py:13) warning
# .env
log__formatters__my_formatter__datefmt='%m-%d %H:%M:%S'
log__formatters__my_formatter__format='{asctime} [{name}] {levelname:>7} ({filename}:{lineno}) {message}'
log__formatters__my_formatter__style='{'

log__handlers__my_handler__class_='logging.StreamHandler'
log__handlers__my_handler__formatter='my_formatter'

log__loggers__root__level='DEBUG'
log__loggers__root__handlers='["my_handler"]'

# is equivalent to:

# log__formatters__my_formatter='{"datefmt":"%m-%d %H:%M:%S","format":"{asctime} [{name}] {levelname:>7} ({filename}:{lineno}) {message}","style":"{"}'
# log__handlers__my_handler='{"class_":"logging.StreamHandler","formatter":"my_formatter"}'
# log__loggers__root='{"level":"DEBUG","handlers":["my_handler"]}'

# and/or:

# log__formatters='{"my_formatter":{"datefmt":"%m-%d %H:%M:%S","format":"{asctime} [{name}] {levelname:>7} ({filename}:{lineno}) {message}","style":"{"}}'
# log__handlers='{"my_handler":{"class_":"logging.StreamHandler","formatter":"my_formatter"}}'
# log__loggers='{"root":{"level":"DEBUG","handlers":["my_handler"]}}'

Loggings

  • not_set
  • base
  • rich

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

pydantic-loggings-1.6.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

pydantic_loggings-1.6.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pydantic-loggings-1.6.1.tar.gz.

File metadata

  • Download URL: pydantic-loggings-1.6.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pydantic-loggings-1.6.1.tar.gz
Algorithm Hash digest
SHA256 2b0b6632a92d3a7a3ed6f362300e0a0c33a6cee76d7b394d3a8686d37b799995
MD5 7740a2c8d4c8a161380bffd688e71c2b
BLAKE2b-256 ea494a32facad60f425239696f4c9fa009bf8e5167bf0d80429620d5da99cd5e

See more details on using hashes here.

File details

Details for the file pydantic_loggings-1.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_loggings-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 712f874121893412339adbb4fa7f1fd9b15c400189158d9a432bc500a3eaa41c
MD5 84a99d3ed1c7981ba2c3284323fc6299
BLAKE2b-256 db5618ad34efb83d7608b0adc6611092a5ee5d4e495b29bd4c2cd8b235be11d5

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