Default is SolarizedDark (IceCream-compatible)

December 7, 2025 ยท View on GitHub

LitPrinter Logo

๐Ÿ”ฅ LitPrinter

IceCream + Rich = LitPrinter โ€” The ultimate debug printing library for Python

A powerful fusion of IceCream-style debugging with Rich-style formatting, syntax highlighting, and beautiful tracebacks.

Version Python License IceCream Compatible

๐Ÿš€ Why LitPrinter?

LitPrinter is a drop-in replacement for IceCream with additional Rich-style features:

Featureprint()IceCreamLitPrinter
Shows variable namesโŒโœ…โœ…
Syntax highlightingโŒโœ…โœ…
Rich-style panelsโŒโŒโœ…
Pretty tracebacksโŒโŒโœ…
Configurable colorsโŒโŒโœ…
Enable/disable toggleโŒโœ…โœ…

โšก Quick Start

pip install litprinter
# No import needed! ic is automatically available
x = 42
ic(x)  # Output: ic| x: 42

That's it! After installing, ic() is automatically available in all your Python scripts - no import required!

๐ŸŽฏ IceCream-Compatible API

LitPrinter is fully compatible with IceCream's API:

from litprinter import ic

# Basic debugging
x, y = 10, 20
ic(x, y)  # ic| x: 10, y: 20

# Works with expressions
ic(x * 2)  # ic| x * 2: 20

# Configure output
ic.configureOutput(prefix='DEBUG| ')
ic.configureOutput(includeContext=True)

# Enable/disable
ic.disable()  # Silent, but still returns values
ic.enable()   # Re-enable output

# Format without printing
s = ic.format(x, y)

๐ŸŽจ Color Themes

LitPrinter includes multiple color themes:

from litprinter import ic, set_style, SolarizedDark, LitStyle, CyberpunkStyle, MonokaiStyle

# Default is SolarizedDark (IceCream-compatible)
ic(x)

# Switch to vibrant LitStyle
set_style(LitStyle)
ic(x)

# Try neon Cyberpunk
set_style(CyberpunkStyle)
ic(x)

# Classic Monokai
set_style(MonokaiStyle)
ic(x)

Available Themes:

  • SolarizedDark - IceCream-compatible (default)
  • LitStyle - Vibrant and modern
  • CyberpunkStyle - Neon pink, teal, green
  • MonokaiStyle - Classic code editor theme

โœจ Features

๐Ÿ“Š Smart Object Formatting

data = {
    "users": ["alice", "bob"],
    "settings": {"theme": "dark"}
}
ic(data)  # Formatted with proper indentation and highlighting

๐Ÿ” Context-Aware Output

def calculate_total(a, b):
    ic(a, b, includeContext=True)
    # Output: ic| [script.py:3 in calculate_total()] >>> a: 10, b: 20
    return a + b

๐Ÿงต Inline Usage

# Use inline - ic() returns the value
result = ic(calculate(x))  # Prints AND returns the value

๐Ÿ’ฅ Beautiful Tracebacks

from litprinter.traceback import install

install(
    theme="cyberpunk",
    show_locals=True,
    extra_lines=3
)

# Now all exceptions show beautiful tracebacks!

๐Ÿ–ผ๏ธ Rich-Style Panels

from litprinter import Panel, Console

# Create bordered panels
panel = Panel("Hello, World!", title="Greeting")
print(panel)

# Rich-style console
console = Console()
console.print("[bold red]Error:[/bold red] Something went wrong!")

๐Ÿ”ง Configuration

Global Configuration

from litprinter import ic

ic.configureOutput(
    prefix='DEBUG| ',           # Custom prefix
    includeContext=True,        # Show file/line/function
    contextAbsPath=False,       # Use relative paths
    outputFunction=my_logger,   # Custom output function
)

Per-Call Override

ic(x, includeContext=True)  # Override for this call only

Custom Formatters

from litprinter import argumentToString

class MyClass:
    def __init__(self, name):
        self.name = name

@argumentToString.register(MyClass)
def format_myclass(obj):
    return f"MyClass({obj.name})"

ic(MyClass("test"))  # ic| MyClass(test)

๐ŸŒ Always Available

After pip install litprinter, ic() is automatically available in all Python scripts - no import needed!

# my_script.py - no import required!
x = 42
ic(x)  # Just works!

If you want to temporarily disable:

from litprinter import uninstall
uninstall()  # Remove ic from builtins

# To re-enable:
from litprinter import install
install()

๐Ÿ“ฆ Migration from IceCream

Just change your import:

# Before
from icecream import ic

# After
from litprinter import ic

All IceCream features work identically, plus you get:

  • Multiple color themes
  • Rich-style panels and console
  • Beautiful tracebacks
  • Panel rendering

๐Ÿ“š API Reference

Main Functions

FunctionDescription
ic(*args)Debug print with variable names
ic.configureOutput(...)Configure output settings
ic.disable() / ic.enable()Toggle output
ic.format(*args)Format without printing
set_style(style)Set color theme

Aliases

AliasSame as
LITic
litprintic
litic

Traceback Functions

FunctionDescription
traceback.install(**kwargs)Install pretty tracebacks
traceback.uninstall()Restore default tracebacks
PrettyTraceback(...)Create traceback formatter

๐Ÿ†• What's New in v0.3.0

  • IceCream-compatible API: Full ic.configureOutput(), ic.disable(), ic.enable() support
  • Multiple color themes: SolarizedDark, LitStyle, CyberpunkStyle, MonokaiStyle
  • Style switching: set_style() to change colors at runtime
  • Rich-style features: Console, Panel, styled text
  • Pretty tracebacks: Frame suppression, max_frames, Rich protocols
  • Dynamic versioning: Version from __init__.py
  • Cleaner codebase: Removed duplicate code, simplified architecture

๐Ÿค Contributing

Contributions are welcome! See CONTRIBUTING.md for details.


Made with โค๏ธ by OEvortex

Telegram Instagram LinkedIn Buy Me A Coffee