Skip to main content

A lightweight Python decorator for measuring execution time and system resource usage.

Project description

🚀 logg_it - Python Logging Utility

logg_it is a versatile logging utility designed to simplify logging for Python applications, featuring powerful stdout capture, automated exception logging, and customizable output.


✨ Features

  • Automatic Exception Logging: Automatically logs exceptions and highlights the problematic line.
  • Stdout Capture: Captures outputs from print() statements.
  • Multiple Outputs: Supports logging to console, file, or both.
  • Flexible Logging Levels: Customizable verbosity (DEBUG, INFO, WARNING, ERROR).
  • Custom Formats: Define custom log message structures.
  • Error-Focused Mode: Optionally logs only errors.
  • Function Tagging: Tags logs with the originating function name.
  • Highlight Errors: Clearly identifies error locations.

📦 Installation

pip install easy-py-logger

⚡ Quick Examples

Decorator Example

from easy-py-logger import logg_it

@logg_it(log_file='logs/example.log', level=logging.DEBUG)
def sample_function():
    print("Hello from function!")
    raise ValueError("Example Exception")

Context Manager Example

with logg_it(log_file='logs/example.log', level=logging.INFO):
    print("Hello from context!")
    1 / 0  # Automatically logs exception

⚙️ Parameters

Parameter Type Default Description
log_file str None Path for file logging. Optional.
level int logging.INFO Logging level.
log_to_console bool True Output logs to console.
log_format str Default format Customizable log format.
log_errors_only bool False If true, logs only errors.

🛠️ Development

Clone repository for local development:

git clone https://github.com/brianvess/easy-py-logger.git
cd your-repo
pip install -e .

📄 Example Log Output

2024-03-10 10:15:00 - INFO - Captured Output: "Hello from function!"
2024-03-10 10:15:01 - ERROR - Exception in [sample_function]: ValueError: Example Exception
🔴 🔥 **sample.py, line 4**

file.name 🌟 Credits

Developed by Brian Vess. If you find this useful, please ⭐ star this repository and contribute! 🚀

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

easy_py_logger-1.0.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

easy_py_logger-1.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file easy_py_logger-1.0.1.tar.gz.

File metadata

  • Download URL: easy_py_logger-1.0.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for easy_py_logger-1.0.1.tar.gz
Algorithm Hash digest
SHA256 22667a4306fc0a2e625ecd1ed60504b881376c2942a690f9488e8790068d2ba3
MD5 7a2eaf8e4d6afb5f48d23d6fa3ae1baf
BLAKE2b-256 7216a4e2ed5567ca8d822bf6acf0e809eb1b420fdca4a432bcaa711e85fcab17

See more details on using hashes here.

File details

Details for the file easy_py_logger-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: easy_py_logger-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for easy_py_logger-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37746d69f93299216f2b45737a21d259602487e9516fd793e46510dd4d9c6af2
MD5 4b23461c89fb7293524cde677dbce2bf
BLAKE2b-256 27313646f40a7835f042b009a3e4b019c8efc41ef3e8b901b398e07beb86dcbd

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