Skip to main content

Logcat style log library

Project description

Logcatter 🐱

See logcatter from PyPI

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 Log class: Log.d(), Log.i(), Log.w(), and Log.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() or sys.stderr.write. And the format of Log is not applied basically. In this case, you can use Log.redirect as a context manager.

from logcatter import Log
Log.init()

with Log.redirect():
    print("Some message")

Log.dispose()

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.save("path of file")

Log.dispose()

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

visual-studio-code-output-example

PyCharm

pycharm-output-exmaple

PowerShell 7 on Windows Terminal

pwsh7-wt-output-example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logcatter-0.3.1.tar.gz (112.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logcatter-0.3.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file logcatter-0.3.1.tar.gz.

File metadata

  • Download URL: logcatter-0.3.1.tar.gz
  • Upload date:
  • Size: 112.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for logcatter-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fa00b0693c485d7ea4d2a04325f68d306365c2ad63543d27972e9480ca08bb51
MD5 5259863e436c930843312aebe44bd825
BLAKE2b-256 3efbc7ad4dcc19d2f099c7fa2775438dfaebdd6a9b77e1509bfb9403312b490a

See more details on using hashes here.

Provenance

The following attestation bundles were made for logcatter-0.3.1.tar.gz:

Publisher: python-publish.yml on RivMt/logcatter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logcatter-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: logcatter-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for logcatter-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4708aa9d076736a38169127a132804bbd57b87884e0d69befb6aa2cbc3be653a
MD5 2f9d2e096e1c62d2629ac3c72dcd156c
BLAKE2b-256 92aee924a51f4d8a6574416523da2e33d56c9c2ef9dac29b6dc1068ffa048709

See more details on using hashes here.

Provenance

The following attestation bundles were made for logcatter-0.3.1-py3-none-any.whl:

Publisher: python-publish.yml on RivMt/logcatter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page