Skip to content

OEvortex/JPRINT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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.

About

A Python library for enhanced printing and debugging

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages