Poweful function that will help you with debugging.
Project description
Simple print
Powerful debugging & logging function.
Userful for bash
console messages (debug) & rabbitmq
proxy messages (logging).
https://github.com/Sobolev5/simple-print
For local development (minimal version)
Install
To install run:
pip install simple-print
Add the following line at the top of your *.py file:
from simple_print import sprint
Print your variables:
master = "yoda"
sprint(master)
sprint(master, c="blue") # colors: grey, red, green, yellow, blue, magenta, cyan, white.
sprint(master, c="blue", b="on_white") # backgrounds: on_grey, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan
sprint(master, c="blue", b="on_white", a="bold") # attributes: bold, dark, underline, blink, reverse, concealed
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
Open development console and see the result:
p
param is False
by default, but you can override this behavior with SIMPLE_PRINT_PATH_TO_FILE=True
in your local environment.
Disable printing
Stop printing:
export DEBUG=False
Test
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
TODO
Kafka support & PyQt support
Try my free time tracker
My free time tracker for developers Workhours.space.
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.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26b0c23adf8818727cba13ec43e579f33bbbad91811fd2c6e91f5ae3c63fdfc6 |
|
MD5 | a6b419ea2a62237f30f2e5048d6a3c6a |
|
BLAKE2b-256 | 74f3c7c11d68098670a3b1fb7e665bf810e787aab4c2c8d8ff22e1f4e1b334dc |