Local development tool for logs printing.
Project description
Simple print
Local development tool for logs printing.
https://github.com/Sobolev5/simple-print
Install
To install run:
pip install simple-print
Features
- Variable value on the first line, metadata (type, file, line, function, time) on the second line
- Clickable file paths in terminal output — Cmd+click (macOS) or Ctrl+click (Linux/Windows) to jump to source
- Colors, backgrounds, attributes, indentation
sprint
Print variables with its names:
master = "yoda" # variable name master
sprint(master)
sprint(master, c="magenta")
sprint(master, c="white", b="on_blue")
sprint(master, c="blue", b="white", a="underline")
sprint(master, c="blue", b="on_white", a="bold", p=True)
master_as_s = sprint(master, s=True) # return as string
master_as_s_with_path = sprint(master, s=True, p=True) # return as string with path to file
ccolor [grey, red, green, yellow, blue, magenta, cyan, white].
bbackground [on_grey, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan].
aattribute [bold, dark, underline, blink, reverse, concealed].
ppath [True/False] with path to file.
llight [True/False] print without fn name and lineno (shortcut lprint).
iindent [1..40].
sstring [True/False] return as string.
rreturn [True/False] print and return as string.
fforce print [True/False] ignore SIMPLE_PRINT_ENABLED=False for docker production logs for example.
streamoutput stream [stdout, stderr, null]. stdout by default. null means no print.
Example with indent
Indent print:
def test_indent():
fruits = ["lemon", "orange", "banana"]
sprint(fruits, c="green")
for fruit in fruits:
sprint(fruit, c="yellow", i=4)
lprint
Light version of sprint (no metadata line). Also available as lsprint for backward compatibility.
master = "yoda" # variable name master
lprint(master)
SprintErr
Minified error traceback with box frame.
from simple_print import SprintErr
bob = []
with SprintErr(l=30):
bob[2] # pretty error traceback (show 30 lines)
spprint
Pretty print dict with box frame.
from simple_print import spprint
spprint({"hello": "world", "lorem": "ipsum"})
spprint({"hello": "world", "lorem": "ipsum"}, i=20) # with indent
Env
Stop printing on production:
export SIMPLE_PRINT_ENABLED=False
Test
pytest -s
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_print-2.2.8.tar.gz.
File metadata
- Download URL: simple_print-2.2.8.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b53bc38aa8690d71030dfc47b6c57075e61ec957ad3f44d6fdc178dd787dfbbc
|
|
| MD5 |
b09f23ce6c70ae10e20e4e334d0df9f5
|
|
| BLAKE2b-256 |
9559f01e84b453059e20ef1b46d0b356c8b8303d69c2f125e35f8ed988f0dea0
|
File details
Details for the file simple_print-2.2.8-py3-none-any.whl.
File metadata
- Download URL: simple_print-2.2.8-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a525f25820cb105be8a2887da09d5a62a903910cf95b6c0480cb07b964dce67e
|
|
| MD5 |
8a5741da40d4a2261dea00eae9b10351
|
|
| BLAKE2b-256 |
c943f378508a77e2a25423a68adef9075c2ff57bc19a851c54ac5ddfc043a2fd
|