Skip to main content

An advanced logging package for Python projects

Project description

Pro Logging

Pro Logging is an advanced, fully customizable logging package for Python projects. It allows developers to log their application's processes to both a log file and an optional database. This package supports various features such as log rotation, different log levels, JSON format logging, and database storage.

Features

  • Log Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
  • Log Rotation: Supports both file size-based and date-based log rotation
  • JSON Format: Option to log messages in JSON format
  • Database Logging: Store logs in an SQLite database for easier management and analysis
  • Console Output: Print log messages to the console
  • Customization: Users can configure log file name, log levels, rotation settings, and more

Installation

Install the package using pip:

pip install pro-logging

Usage

Here's a basic example of how to use the pro-logging package:

from pro_logging import AdvancedLogger

# Initialize the logger
logger = AdvancedLogger(
    log_filename='app.log',  # Log file name
    level="DEBUG",           # Log level
    log_to_console=True,     # Output to console
    rotate_logs=True,        # Enable log rotation
    max_size_mb=10,          # Maximum log file size before rotation
    json_format=True,        # Log in JSON format
    db_path='app_logs.db'    # Path to the SQLite database for logs
)

# Log some messages
logger.log_info("This is an informational message.")
logger.log_error("This is an error message.")
logger.log_debug("This is a debug message.")

Example

Logging with Different Levels

logger.log_debug("Debugging the application")
logger.log_info("Application is running")
logger.log_warning("This is a warning")
logger.log_error("An error occurred")
logger.log_critical("Critical system failure")

Log Rotation

You can rotate logs based on file size or date.

# Enable file size-based log rotation
logger = AdvancedLogger(rotate_logs=True, max_size_mb=5)

# Enable date-based log rotation
logger = AdvancedLogger(date_based_rotation=True)

Database Logging

Logs can also be stored in an SQLite database for further analysis.

logger = AdvancedLogger(db_path='app_logs.db')

# Log messages will be saved in the database
logger.log_info("This log is saved in the database as well.")

Customization

You can adjust log settings such as file name, log level, JSON formatting, and more:

logger = AdvancedLogger(
    log_filename='custom.log',
    level="WARNING",
    json_format=True
)

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

pro-logging-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

pro_logging-1.0.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pro-logging-1.0.0.tar.gz.

File metadata

  • Download URL: pro-logging-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for pro-logging-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d9a9707bf4d5de00ab17d6df0c7fef847e6a792339445d2116b91454eafd2169
MD5 8b2e4bd67c6a3e85bee4e937f8318156
BLAKE2b-256 b9ee54a2ba2e902333f33548bfe2f7cacdb4a3c00d3e2c7e0dbcb3343a3a7c32

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pro_logging-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for pro_logging-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 248fa070d1d54c6848c23a6521bc7738e399cb8c41a0afb948ca0520f18c2de1
MD5 b71f1b0e7ff75323a7606627790a376c
BLAKE2b-256 cca69f25a6cd81f5d34d706d433541fc3655bc396b3f5ac32dfea3504b0a9495

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