Powerful debugging & logging tool for Python.
Project description
Simple print
Powerful debugging & logging tool for Python.
Userful for bash
console messages (debug) & rabbitmq
proxy messages (logging).
https://github.com/Sobolev5/simple-print
For local development
Install
To install run:
pip install simple-print
Print variables
Function params:
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 [with path to file]
i
indent [indent 1..40]
s
string [return as string]
f
force print [override DEBUG=False]
from simple_print import sprint
master = "yoda"
sprint(master)
sprint(master, c="blue")
sprint(master, c="blue", b="on_white")
sprint(master, c="blue", b="on_white", a="underline")
sprint(master, c="blue", b="on_white", a="bold", p=True)
my_string = sprint(master, s=True) # return as string
my_string = sprint(master, s=True, p=True) # return as string with path to file
Result:
p
param is False
by default, but you can override this behavior with SIMPLE_PRINT_PATH_TO_FILE=True
in your local environment.
Example with indent
For indent use i
param:
def test_indent():
fruits = ["lemon", "orange", "banana"]
sprint(fruits, c="green")
for fruit in fruits:
sprint(fruit, c="yellow", i=4)
Result:
Disable printing
Stop printing:
export DEBUG=False
Test
export DEBUG=True && pytest test/test_print.py -s
For catch messages on production server
Install
To install run:
pip install simple-print[broker]
Add the following line at the top of your *.py file:
from simple_print import throw, catch
Now you can send messages to rabbitmq queue amq.direct
.simple_print
(by default):
throw({"tag":"tag", "msg":{"any_key":"any val"}}, uri="amqp://admin:pass@0.0.0.0:5672/vhost") # default queue
throw({"exchange":"any_exchange", "routing_key":"any_key", "tag":"tag", "msg":{"any_key":"any val"}}, uri="amqp://admin:pass@0.0.0.0:5672/vhost") # with custom routing key
Catch last 10 messages from RabbitMQ:
catch(tag="tag", count=10, uri="amqp://admin:pass@0.0.0.0:5672/vhost") # default queue
catch(queue="queue", tag="tag", count=10, console=True, uri="amqp://admin:pass@0.0.0.0:5672/vhost") # custom queue
Test
pytest test/test_broker.py -s
Integrations
simple-print[broker]
is default logger for upserver
(montoring & logging system).
Go to https://github.com/Sobolev5/upserver for further instructions.
Time tracker for developers
Use Workhours.space for your working time tracking. It is free.
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 Distributions
Built Distribution
Hashes for simple_print-1.6.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c275d6cf47ebc34ba046822f6a2a0701afa61f3dfecd2edc2dbb6db33967201 |
|
MD5 | ed3674860a76782639b6a9d3a5154e63 |
|
BLAKE2b-256 | 33b793b98c2d1d90c046222857b9a640604c31cdeac104762265e00a5ae77f38 |