Skip to main content

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 

c color [grey, red, green, yellow, blue, magenta, cyan, white].
b background [on_grey, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan].
a attribute [bold, dark, underline, blink, reverse, concealed].
p path [True/False] with path to file.
l light [True/False] print without fn name and lineno (shortcut lprint).
i indent [1..40].
s string [True/False] return as string.
r return [True/False] print and return as string.
f force print [True/False] ignore SIMPLE_PRINT_ENABLED=False for docker production logs for example.
stream output 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_print-2.2.8.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

simple_print-2.2.8-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

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

Hashes for simple_print-2.2.8.tar.gz
Algorithm Hash digest
SHA256 b53bc38aa8690d71030dfc47b6c57075e61ec957ad3f44d6fdc178dd787dfbbc
MD5 b09f23ce6c70ae10e20e4e334d0df9f5
BLAKE2b-256 9559f01e84b453059e20ef1b46d0b356c8b8303d69c2f125e35f8ed988f0dea0

See more details on using hashes here.

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

Hashes for simple_print-2.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a525f25820cb105be8a2887da09d5a62a903910cf95b6c0480cb07b964dce67e
MD5 8a5741da40d4a2261dea00eae9b10351
BLAKE2b-256 c943f378508a77e2a25423a68adef9075c2ff57bc19a851c54ac5ddfc043a2fd

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