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 DEBUG.
  • 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.1.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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_configurator_logger-1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 88c2bcfb018de2d17969dfa01625f01c931a29ba19db53ea9650a0e8503bc9f3
MD5 1efc6a5f1fca89a6e8e3348ceab0ccdf
BLAKE2b-256 816b41d7718759c020ad3e3a5573832ef2aee1d5338be709a400d1d321180839

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_configurator_logger-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1a2b3ee39146e3b18eeee90dd2a1f13b9b79e2fd42b1d6a377fb6ff00cc9e6f
MD5 df44a3397f05cd55e04aaf82472f852a
BLAKE2b-256 b59ac1bbd5cecf10ad21b554f6b97eebcde63d3d5074bcbd02f040c43515fba4

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