LogSpot
LogSpot is a lightweight, reusable Flask extension that adds a /logs route to your application, allowing you to view, filter, search, and download logs directly from the browser. It also provides a simple logging interface attached to your Flask app instance.
Features
- Instant Log Viewer: Access your application logs at
/logs. - Filtering: Filter logs by severity level (INFO, DEBUG, WARN, ERROR, CRITICAL).
- Search: Search for specific keywords in your logs.
- Pagination/Limit: Control the number of log lines displayed.
- Download: Download logs as a file for offline analysis.
- Simple API: Easy-to-use logging methods attached directly to your Flask
appobject. - Alerts: Send Telegram alerts for critical errors.
Installation
You can install LogSpot using pip:
pip install logspot
Or install directly from the source:
pip install git+https://github.com/rishabhpandey106/logspot.git
Quick Start
Here's how to integrate LogSpot into your Flask application:
from flask import Flask
from logspot import setup_logs
app = Flask(__name__)
# Initialize LogSpot
# This registers the /logs blueprint and attaches logging methods to 'app'
logger = setup_logs(app, service="resbot",telegram_chat_id=TELEGRAM_CHAT_ID)
@app.route("/")
def index():
# Use the attached logging methods
logger.info("Index page accessed")
return "Hello, World!"
@app.route("/error")
def trigger_error():
logger.error("Something went wrong!", notify=True)
return "Error logged", 500
if __name__ == "__main__":
app.run(debug=True)
Now, run your app and visit http://localhost:5000/logs to see your logs!
Usage
Logging Methods
Once initialized, LogSpot attaches the following methods to your Flask app instance:
logger.info(message)logger.debug(message)logger.warn(message)logger.error(message)logger.critical(message)
The /logs Endpoint
The /logs route supports several query parameters to help you find what you need:
| Parameter | Description | Default | Example |
|---|---|---|---|
limit |
Number of recent log lines to show | 200 |
/logs?limit=50 |
level |
Filter by log level (INFO, ERROR, etc.) | None |
/logs?level=ERROR |
search |
Case-insensitive search for a string | None |
/logs?search=database |
download |
Set to true to download logs as a .log file |
false |
/logs?download=true |
Examples:
-
Show last 50 error logs:
GET /logs?limit=50&level=ERROR -
Search for "connection failed":
GET /logs?search=connection%20failed -
Download all logs:
GET /logs?download=true&limit=0(Uselimit=0or a very large number to get all logs, though default is 200)
License
This project is licensed under the MIT License.
Release files for logspot 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| logspot-0.5.0.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| logspot-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / logspot-0.5.0.tar.gz
| Download URL | logspot-0.5.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6bc5615aae994ac71e851a61f31d85117b598738c5cc3d524c5fe9ddd7109ad
|
|
BLAKE2b-256 checksum How to use checksums |
24d9c0eaa8d383401f893aa323cf53f310d65f4f6740b2e80c5cc578322c1687
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / logspot-0.5.0-py3-none-any.whl
| Download URL | logspot-0.5.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
266b4b54041bbc480a8c5f7903ab6e22a9bc007bbfddc408f383e8fa8a8e2181
|
|
BLAKE2b-256 checksum How to use checksums |
6e2771e54ff9cd0888635c21be18d927c985f8a8cecfeffeef7e330b87bcaa09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|