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

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 lsprint). 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)

lsprint

Light version of sprint.

master = "yoda" # variable name master
lsprint(master)
   

SprintErr

Minified error traceback.

from simple_print import SprintErr

@patch("logging.info", MagicMock(side_effect=[Exception("Something went wrong")]))
def test_sprint_err(self):
   with SprintErr(l=30):
      logging.info("")
  

spprint

Pretty print with indent.

from simple_print import sprrint

spprint(
   {"hello": c"world", "lorem": "ipsum"}, 
   i=20,
)
  

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.7.tar.gz (7.5 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.7-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file simple_print-2.2.7.tar.gz.

File metadata

  • Download URL: simple_print-2.2.7.tar.gz
  • Upload date:
  • Size: 7.5 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.7.tar.gz
Algorithm Hash digest
SHA256 e307991e1d94e0db1d2fad0a68c8947cc0a5e6e4a04d9c2e9a83ee625396fc70
MD5 99d52a218f3467be9b532ec63d18a51c
BLAKE2b-256 56de6bd0c1afbd67e5aad4d355305716d0fea6facc3f06f3acac80b3a3f9c197

See more details on using hashes here.

File details

Details for the file simple_print-2.2.7-py3-none-any.whl.

File metadata

  • Download URL: simple_print-2.2.7-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f92de07ed6e7f545cf4cbc10db897fd674b40919bb8537b486944458bab6ab5b
MD5 40984c3cd01920912d0f86d11fb6ed87
BLAKE2b-256 ace79a6960d4d40464dfe52824f5865e6b3a1d257cedbdf72cae94d162945c36

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