Skip to main content

A simple Python package

Project description

Logger Module

Overview

The Logger module is designed to produce logs for applications with flexible output options. It supports different log data formats and ensures structured logging for better observability.

Features

  • Supports multiple output destinations:
    • Stdout (default)
    • File (logs are stored in app.log)
    • Queue service (S3 storage via Kafka)
  • Supports various log data formats:
    • Space-separated key-value pairs: key:value key:value
    • Comma-separated key-value pairs: key:value, key:value
    • JSON or direct objects: {key:value, key:value}
    • Quoted JSON-like objects: '{key:value, key:value}'
  • Default log fields included:
    • Timestamp (ISO format)
    • Log level (INFO, WARN, DEBUG, ERROR)

Installation

pip install vtb_logger

Usage

Initializing the Logger

from vtb_logger import Logger

logger = Logger(service_id="my_system:my_service", log_type="file")
  • service_id: Required when using que log type (Format: <system-name>:<service-name>)
  • log_type: Options are stdout (default), file, or que

Logging Messages

logger.info(data="key1:value1 key2:value2")  # Space-separated
logger.warn(data="key1:value1, key2:value2") # Comma-separated
logger.debug(data='{"key1":"value1", "key2":"value2"}')  # JSON
logger.error(data={"key1": "value1", "key2": "value2"})  # Direct object

Required Environment Variables

For queue-based logging, set the following:

export BOOTSTRAP_SERVER=<kafka_queue_connection>

Implementation Details

  • __detect_data_format(data): Identifies the log data format
  • __log_formatter(level, data): Formats logs according to the identified data structure
  • __log_controller(log): Routes logs to the appropriate destination (stdout, file, or que)

License

This module is provided under the MIT License.


For more details, refer to the official documentation or contact support.

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

vtb_logger-2.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

vtb_logger-2.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file vtb_logger-2.1.0.tar.gz.

File metadata

  • Download URL: vtb_logger-2.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for vtb_logger-2.1.0.tar.gz
Algorithm Hash digest
SHA256 4ce2aaa473a8f6e35e316c9b162635e0cf3c9313e8e2b615d6cdb51c79ca843b
MD5 39911c4e33786aecf49ce6e3fb683b61
BLAKE2b-256 f4363831b212c1af1f58de4e671c59ecb0d368a29402c3ea21c7fcd7d31b604f

See more details on using hashes here.

File details

Details for the file vtb_logger-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: vtb_logger-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for vtb_logger-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74f9451f54ab0faef60409295b7e7ba8a96c5ae1646d7515aaf5d7f95d92fbd9
MD5 5401decc189e8a7a13dbe1f3a19dfeed
BLAKE2b-256 8bc19217d87048ff7b06ea1d55b0a3cd7f643fd2f2ea4a05c8927c25c4d43134

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