Skip to main content

A custom logger which includes json log format and plain text log format

Project description

Py Configurator Logger

Py Configurator Logger is a Python package designed to simplify logging configuration and usage within your projects. It provides a flexible logger setup with customizable output formats and log levels.

Installation

You can install Py Configurator Logger via pip:

pip install py-configurator-logger

Usage

Basic Usage

from py_configurator_logger import ConfiguratorLogger

# Initialize logger
configurator_logger = ConfiguratorLogger(logger_name='my_logger')
logger = configurator_logger.get_logger()

# Log messages
logger.debug('Debug message')
logger.info('Info message')
logger.warning('Warning message')
logger.error('Error message')
logger.critical('Critical message')

# Log custom level
logger.trace('Trace message')

# You can also provide extra parameters to the logger, such as:
logger.info('User logged in', extra={'user_id': 123, 'username': 'example_user'})

This allows for additional contextual information to be included in the log messages.

Configuration

Py Configurator Logger utilizes configurations from environment variables loaded from .env files within the directory. You can customize the logging behavior by setting the following environment variables:

  • logs_level: Adjusts the log level. The default level is set to INFO.
  • logs_output_format: Specifies the log output format, which can be either plain_text or json. The default format is plain_text.
  • log_text_format: Sets the log format for plain text output. The default format is %(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s.
  • log_json_format: Sets the log format for JSON output. The default format is {"timestamp": "%(asctime)s", "level": "%(levelname)s", "filename": "%(name)s", "lineno": "%(lineno)d", "message": "%(message)s"}.

Sample .env file

logs_level=trace
logs_output_format=json

You can also add log_text_format and log_json_format for further customization of the logging output formats for plain text and JSON output.

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

py_configurator_logger-1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

py_configurator_logger-1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file py_configurator_logger-1.0.tar.gz.

File metadata

  • Download URL: py_configurator_logger-1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.1

File hashes

Hashes for py_configurator_logger-1.0.tar.gz
Algorithm Hash digest
SHA256 bcae873c13164a181ec92ef88f7867b93aacf07b0fb9ee5a0f53e504193f4845
MD5 967ddbe5872ea42fad5f893e6bb4bf94
BLAKE2b-256 1624f69ccb16333ba7715149575236467d00fd26077ace76a81420730e745802

See more details on using hashes here.

File details

Details for the file py_configurator_logger-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_configurator_logger-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11f00b94c136ff44446e0758ea07ee43ed3bffe1526df4c95043ea4599b4368e
MD5 f2cca0fa4fc1bef9274256595eae81c3
BLAKE2b-256 1cc99db24e41247ab65fe1866f637babebe95d1f7fcbd138b0f9cc2a3d25934a

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