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! πͺ
- What's
jprinterAll About? - Key Features That Keep It π―
- How to Use
jprinterLike a Pro - Installation - Keeping It Simple
- Package Structure - Know Your Tools
- Output Format Examples - See It to Believe It
- Advanced Usage - Level Up Your Debugging Game
- Troubleshooting - When Things Get Tricky
- Let's Level Up Together!
- License - Keeping It Open and Free
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. π€
- 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. π¨
sepandend: Full control over separators and end-of-line characters, just like the originalprint(). π€- 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
jprinteroutput 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! ποΈ
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")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")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")Set custom prefixes for different debugging sections:
from jprinter import jp
jp("Debug info here", prefix="DEBUG >>> ")
jp("Important note", prefix="NOTE >>> ")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})Use custom separators:
from jprinter import jp
jp("Keep", "it", "real", sep=" - ")Log your output to a file:
from jprinter import jp
jp("This is a log message", log_file="debug.log")Just drop the jprinter folder into your project's directory, and you're good to go! π― No extra installations needed.
If you like to keep it clean, install jprinter with pip:
pip install jprinterTo use jprinter as a built-in function, edit builtins.py in your Python installation:
-
Locate
builtins.py: Usually found in your Python installation directory. -
Edit
builtins.py: Add the following lines to the file:from jprinter import jprint as print
-
Restart Python: This will make the changes effective.
__init__.py: Initializes thejprinterpackage.builtins.py: Functions to integratejprinterwith Python builtins.coloring.py: Handles the color magic.core.py: The heart ofjprinterwith all the core functionality.jp.py: Thejpfunction for quick debugging.jprint.py: The main module forjprint.README.md: This file, for all the important documentation.
from jprinter import jp
jp("Hello, world!")Output:
JARVIS -> [test_jprint.py:2] in () >>> Hello, world!
from jprinter import jprint
jprint("Hello, world!")Output:
JARVIS -> [test_jprint.py:2] in () >>> Hello, world!
from jprinter import jp
jp("Hello, world!", prefix="DEBUG >>> ")Output:
DEBUG >>> [test_jprint.py:2] in () >>> Hello, world!
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"
]
}
from jprinter import log
log("This is a warning", level="warning")Output:
[WARNING] JARVIS -> [test_jprint.py:2] in () >>> This is a warning
See how to use the global enable/disable and logging in the How to Use section.
ImportError: Make sure you have installed or copied the files properly.- Output Not Working: Make sure the
JPrintDebuggeris enabled and configured.
jprinter the best tool for all the devs out there! πͺ