https://github.com/levinotik/sprawl
Python utility package for louder logging
https://github.com/levinotik/sprawl
debugging formatting logging python python3
Last synced: 9 days ago
JSON representation
Python utility package for louder logging
- Host: GitHub
- URL: https://github.com/levinotik/sprawl
- Owner: levinotik
- Created: 2019-12-12T02:01:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-12T02:17:14.000Z (over 6 years ago)
- Last Synced: 2025-10-13T08:39:01.033Z (9 months ago)
- Topics: debugging, formatting, logging, python, python3
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sprawl
A utility package for printing formatted, colorized log messages.
## Why?
Sometimes we fall back to good ol' print-driven development ("PDD")
when we need to inspect values at runtime. It can be annoying to search through
a terminal window filled with other logs to find the one log statement you're looking
for. This makes it easy for your log messages to stand out.
## Installation
`$ pip install sprawl`
## Usage
Import the log function:
```python
from sprawl.loud_log import log
```
Configure logging however you normally would, for example:
```python
logging.basicConfig(format='%(asctime)s \n %(message)s', level=logging.INFO)
```
log a message using the defaults:
```python
log('my log message')
```
prints:
```
##################################
my log message
##################################
```
Center the log message:
```python
log('my log message', center_message=True)
```
prints:
```
##################################
my log message
##################################
```
Change the surrounding character:
```python
log('my log message', center_message=True, char_to_surround_with='~')
```
prints:
```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my log message
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Add some color:
```python
log('my log message', center_message=True, color='yellow')
```
prints:

Log the name of the function or module from within which this log() was called
```python
def my_amazing_function():
log('my log message', center_message=True, print_func_name=True)
my_amazing_function()
```
prints:
```
log called from my_amazing_function
#################################
my log message
#################################
```