Logcat style log library
Project description
Logcatter 🐱
Brings the familiar convenience and readability of Android's Logcat to your Python projects.
Tired of complex logger configurations? Logcatter lets you use intuitive methods like Log.d() and Log.i() right away. It automatically tags logs with the calling filename, dramatically speeding up your debugging workflow.
✨ Key Features
- ☕ Android Logcat Style: Get beautiful, easy-to-read logs formatted as
yyyy-MM-dd HH:mm:ss.SSS [D/tag] message. - 🏷️ Automatic Tagging: The name of the source file (
main.py) that calls the log is automatically used as the tag, so you can instantly identify the origin of a log. - 🎨 Colored Output: Log levels (Debug, Info, Warning, Error) are color-coded for enhanced visual recognition.
- 🚀 Concise API: Use intuitive methods nearly identical to the Android
Logclass:Log.d(),Log.i(),Log.w(), andLog.e(). - 🔧 Zero Configuration: Works right out of the box after installation with no extra setup required.
📦 Installation
pip install logcatter
🚀 Quick Start
Just import the Log class into your project and call Log.init() first and Log.dispose() last of your code.
from logcatter import Log
Log.init()
Log.d("This is log!!")
Log.set_level(Log.WARNING) # Hide DEBUG, INFO level logs
Log.i("This is info!!") # You cannot see this because you set the minimum level `WARNING`
Log.e("ERROR!!!", e=ValueError()) # You can log the caught exception/error with argument `e`
Log.f("FATAL ERROR", s=True) # You can log the stacktrace with flag `s`
Log.dispose()
Using with other's code
Some library or codes are using print(). And the format of Log is not applied basically to this. In this case, you can use Log.redirect as a context manager.
import sys
from logcatter import Log
Log.init()
with Log.redirect(
stdout=Log.VERBOSE,
stderr=None,
):
print("Some message")
sys.stderr.write("stderr message\n")
Log.dispose()
Output:
1970-01-01 00:00:00 000 [V/<stdin>] Some message
stderr message
stdout outputs (include print) will be handled a VERBOSE level. You can change this by parameter stdout. If the value is None, Log.redirect does not redirect stdout.
Same as stdout, you can redirect stderr outputs by parameter stderr. But the default value is None.
If internal print codes use CR (carriage return) to rewrite last line such as tqdm, the Log style will not be applied.
Save logs
You can save the log messages using just a single line.
from logcatter import Log
Log.init()
Log.i("This will not be saved")
Log.save("path of file")
Log.i("Message saved")
Log.dispose()
Saved log file:
Message saved
Multiprocessing
You can use Log in the multiprocessing with calling Log.init_worker(). (Don't forget the brackets!)
from logcatter import Log
import multiprocessing
Log.init()
with multiprocessing.Pool(processes=2, initializer=Log.init_worker()) as pool:
Log.i("Some message")
Log.dispose()
💻 Output Example
Visual Studio Code
PyCharm
PowerShell 7 on Windows Terminal
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logcatter-0.3.2.tar.gz.
File metadata
- Download URL: logcatter-0.3.2.tar.gz
- Upload date:
- Size: 112.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
586fdb4fb01cd8894e9c353e90bb725c3eb6c83705861666af23bea3e7c710fd
|
|
| MD5 |
1289641d9f46bbb0fa56e5af072104ef
|
|
| BLAKE2b-256 |
86553074d24f016ce1114d9e490987b673de47af7b5950a5f61ab42a9129a7b3
|
Provenance
The following attestation bundles were made for logcatter-0.3.2.tar.gz:
Publisher:
python-publish.yml on RivMt/logcatter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logcatter-0.3.2.tar.gz -
Subject digest:
586fdb4fb01cd8894e9c353e90bb725c3eb6c83705861666af23bea3e7c710fd - Sigstore transparency entry: 360975583
- Sigstore integration time:
-
Permalink:
RivMt/logcatter@4d9b579d7adf0865c4f3a6cd7815490b91f911c9 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/RivMt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4d9b579d7adf0865c4f3a6cd7815490b91f911c9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file logcatter-0.3.2-py3-none-any.whl.
File metadata
- Download URL: logcatter-0.3.2-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2efb5a69ba46425518d34b29f2c70e9fc20bddce236f7aef3e4ea19667d47e44
|
|
| MD5 |
457b6e864177c06200a62b5f8a244bb6
|
|
| BLAKE2b-256 |
a21a765bc06aea780105d8639adfe1dfc99842eec5fd69071a0b68c5368ebc7b
|
Provenance
The following attestation bundles were made for logcatter-0.3.2-py3-none-any.whl:
Publisher:
python-publish.yml on RivMt/logcatter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logcatter-0.3.2-py3-none-any.whl -
Subject digest:
2efb5a69ba46425518d34b29f2c70e9fc20bddce236f7aef3e4ea19667d47e44 - Sigstore transparency entry: 360975605
- Sigstore integration time:
-
Permalink:
RivMt/logcatter@4d9b579d7adf0865c4f3a6cd7815490b91f911c9 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/RivMt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4d9b579d7adf0865c4f3a6cd7815490b91f911c9 -
Trigger Event:
release
-
Statement type: