Skip to main content

A Python library for enhanced printing and debugging.

Project description

jprinter - Your Ultimate Debugging Companion! 🔥


Wassup, fam! 👋 Meet jprinter, your new go-to tool for debugging! 💯 This ain't just your regular print() function; we're talkin' next-level debugging that keeps it real and helps you crush those bugs! 💪



Table of Contents


What's jprinter All About? 🤔

jprinter is here to replace that basic print() function and bring your debugging game into the future! 🚀 We know that debugging can be a pain, so we've built this tool with all the features you need to make it real, fast, and efficient. 😤

Key Features That Keep It 💯

  • Enhanced Output: See variable values, context (filename, line number, function name) all in one clean output.
  • Customizable Prefixes: Set a custom prefix to make sure you know what's being printed from which part of your code! 🗣️
  • Built-in Context: Automatically adds the file name, line number, and function name, so you always know where the action is! 📍
  • Colorized Output: Make your output stand out with custom colors that make it easier to read. 🎨
  • sep and end: Full control over separators and end-of-line characters, just like the original print(). 🔤
  • Pretty Printing: Nicely format complex data structures like dictionaries and lists so they're easy to read. ✨
  • File Logging: Log all your output to a file, with or without timestamps, for keeping track of everything. 📝
  • Global Enable/Disable: Turn off all jprinter output with a single command so you can clean up the console when needed. 📴
  • Log Function: Output different log levels (debug, info, warning, error) for better organization and clarity! 🗂️

How to Use jprinter Like a Pro

Basic Usage with jp and jprint

Here's a basic example of how to use jprint and its shortcut, jp:

from jprinter import jp, jprint

# Using jp for a quick print statement
jp("Hello, world!")

# Using jprint with multiple arguments
jprint("This is", "a", "test")

Logging with Different Levels

You can log with different levels using the log function:

from jprinter import log

log("This is a debug message", level="debug")
log("This is an info message", level="info")
log("This is a warning message", level="warning")
log("This is an error message", level="error")

Global Enable/Disable

You can disable and enable all jprinter output using the JPrintDebugger class:

from jprinter import jp
from jprinter.core import JPrintDebugger

jp("This will be printed")
JPrintDebugger.disable_all()
jp("This will not be printed")
JPrintDebugger.enable_all()
jp("This will be printed again")

Custom Prefixes

Set custom prefixes for different debugging sections:

from jprinter import jp

jp("Debug info here", prefix="DEBUG >>> ")
jp("Important note", prefix="NOTE >>> ")

Pretty Printing Complex Data Structures

Format complex data structures for readability:

from jprinter import jp

data = {"name": "HAI", "age": 17, "hobbies": ["coding", "gaming", "reading"]}
jp(data, pprint_options={"indent": 4})

Custom Separators

Use custom separators:

from jprinter import jp

jp("Keep", "it", "real", sep=" - ")

File Logging

Log your output to a file:

from jprinter import jp

jp("This is a log message", log_file="debug.log")

Installation - Keeping It Simple

Option 1: Copy and Paste (The Easiest Way)

Just drop the jprinter folder into your project's directory, and you're good to go! 💯 No extra installations needed.

Option 2: Using pip (For the Pros)

If you like to keep it clean, install jprinter with pip:

pip install jprinter

Option 3: Installing to Python's Builtins (Advanced & Risky)

⚠️ WARNING: Modifying Python's builtins can cause issues and is not recommended. Proceed with caution!

To use jprinter as a built-in function, edit builtins.py in your Python installation:

  1. Locate builtins.py: Usually found in your Python installation directory.

  2. Edit builtins.py: Add the following lines to the file:

    from jprinter import jprint as print
    
  3. Restart Python: This will make the changes effective.


Package Structure - Know Your Tools

Here's a breakdown of the key files:
  • __init__.py: Initializes the jprinter package.
  • builtins.py: Functions to integrate jprinter with Python builtins.
  • coloring.py: Handles the color magic.
  • core.py: The heart of jprinter with all the core functionality.
  • jp.py: The jp function for quick debugging.
  • jprint.py: The main module for jprint.
  • README.md: This file, for all the important documentation.

Output Format Examples - See It to Believe It

Basic jp Usage

from jprinter import jp
jp("Hello, world!")

Output:

JARVIS -> [test_jprint.py:2] in () >>> Hello, world!

Basic jprint Usage

from jprinter import jprint
jprint("Hello, world!")

Output:

JARVIS -> [test_jprint.py:2] in () >>> Hello, world!

Custom Prefix

from jprinter import jp
jp("Hello, world!", prefix="DEBUG >>> ")

Output:

DEBUG >>> [test_jprint.py:2] in () >>> Hello, world!

Pretty Print

from jprinter import jp
data = {"name": "HAI", "age": 17, "hobbies": ["coding", "gaming", "reading"]}
jp(data, pprint_options={"indent": 4})

Output:

JARVIS -> [test_jprint.py:2] in () >>> {
    "name": "HAI",
    "age": 17,
    "hobbies": [
        "coding",
        "gaming",
        "reading"
    ]
}

Logging Output

from jprinter import log
log("This is a warning", level="warning")

Output:

[WARNING] JARVIS -> [test_jprint.py:2] in () >>> This is a warning

Advanced Usage - Level Up Your Debugging Game

See how to use the global enable/disable and logging in the How to Use section.


Troubleshooting - When Things Get Tricky

Common Issues

  1. ImportError: Make sure you have installed or copied the files properly.
  2. Output Not Working: Make sure the JPrintDebugger is enabled and configured.

Let's Level Up Together!

Feel free to contribute to the project by submitting issues or pull requests. Let's make jprinter the best tool for all the devs out there! 💪

License - Keeping It Open and Free

This project is licensed under the Apache 2.0 License.

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

jprinter-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

jprinter-0.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file jprinter-0.1.1.tar.gz.

File metadata

  • Download URL: jprinter-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for jprinter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3cc008185f7538896c8ced7e74bac932df0fe9ec5c899abbbb3ac91b1b2bb63a
MD5 77de3a751f27f12de9727d267a474426
BLAKE2b-256 124e6ead3bb11fb558ae588af3fd9edef4a589785a29de1aa15697f603ca7dbe

See more details on using hashes here.

File details

Details for the file jprinter-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jprinter-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for jprinter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab16fd64b70dc3da7bd83c29a4e3e65bd0139d894607109dcd7b32a0f7ce2135
MD5 df651b42bad60f7a1a0b3826c8b4ba22
BLAKE2b-256 848f5fc29707bc0bbe4fe6480c47a31bc70261c6950e4bb796ce2329f9cbdecf

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