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
Install
To install run:
pip install simple-print
Remote/local debugging
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
export DEBUG=True && pytest test/test_print.py -s
Logging messages [RabbitMQ]
You can log your messages through RabbitMQ queues. In this case you need to setup RabbitMQ connection:
export SIMPLE_PRINT_RABBITMQ_URI="amqp://admin:pass@0.0.0.0:5672/vhost"
After this you can send messages to rabbitmq queue simple_print_queue
(by default):
sprint("see you in simple_print_queue", p=True, broker={"tag": "tag", "msg": {"any_key":"any val"})
sprint("see you in another_queue", p=True, broker={"tag": "tag", "msg": {"any_key":"any val"}, "queue": "another_queue"})
sprint("see you in Clickhouse", p=True, broker={"tag": "tag", "msg": {"any_key":"any val"}, "queue": "clickhouse"}) # see instructions below
With DEBUG=False it also works, so you can catch messages on your production server. To show the last 10 messages from RabbitMQ:
export SIMPLE_PRINT_RABBITMQ_URI="amqp://admin:pass@0.0.0.0:5672/vhost" && python -c "from simple_print.utils import catch; catch(tag='tag', queue='simple_print_queue', count=10)"
Proxy to Clickhouse from RabbitMQ
Open the simple_print/clickhouse.py
for further instructions.
Test
export SIMPLE_PRINT_RABBITMQ_URI="amqp://admin:pass@0.0.0.0:5672/vhost" && pytest test/test_broker.py -s
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.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7269363f68b1e0efcb45c2066d70fa38bec4c7b8de92ec1bf8ed5cbeec354791 |
|
MD5 | 50c698499bd6a74c489f84602a35c395 |
|
BLAKE2b-256 | dedfd73e094f72927ca33ea41445c6e84ee9982f816e0032990ab5f601df0d9b |