A standalone Django package to stream logs over WebSockets.
Project description
Django Live Logs
A lightweight, zero-configuration package that streams your Django server logs directly to a beautiful, real-time web dashboard using WebSockets and Redis.
(Imagine a beautiful dark-mode dashboard here)
Features
- 🚀 Real-Time Streaming: Uses Django Channels and Redis to push logs instantly.
- 🎨 Built-In Dashboard: Comes with a sleek, dark-mode Tailwind CSS interface out of the box.
- 🛡️ Secure by Default: Dashboard and WebSockets are natively protected by Django's
@staff_member_requiredand Session cookies. - 🧵 Non-Blocking: Dispatches logs in a background thread to prevent ASGI async event loop collisions.
- 🔍 Filtering: Instantly filter between
INFO,WARNING, andERRORlogs.
1. Installation
Install the package via pip:
pip install django-live-logs
Note: This package requires channels and channels-redis to be installed and configured in your project.
2. Configuration
Step A: Update settings.py
Add the package to your installed apps:
INSTALLED_APPS = [
# ...
'django_live_logs',
]
Configure your LOGGING dictionary to catch everything (the root logger) and send it to the WebSocket handler:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {'class': 'logging.StreamHandler'},
'websocket': {'class': 'django_live_logs.handlers.WebSocketLogHandler'},
},
'root': {
'handlers': ['console', 'websocket'],
'level': 'INFO',
},
'loggers': {
'django': {
'handlers': ['console', 'websocket'],
'level': 'INFO',
'propagate': False,
}
},
}
Step B: Route the Dashboard (HTTP)
In your main urls.py, include the dashboard URL:
from django.urls import path, include
urlpatterns = [
# ...
path('live-logs/', include('django_live_logs.urls')),
]
Step C: Route the WebSockets (ASGI)
In your asgi.py, make sure your WebSockets are wrapped in Django's AuthMiddlewareStack so it can read your admin session cookies securely. Then include the routing:
from channels.auth import AuthMiddlewareStack
import django_live_logs.routing
application = ProtocolTypeRouter({
"http": get_asgi_application(),
"websocket": AllowedHostsOriginValidator(
AuthMiddlewareStack(
URLRouter(
# Your existing websocket routes + Live Logs routes
your_app_routing.websocket_urlpatterns +
django_live_logs.routing.websocket_urlpatterns
)
)
),
})
3. Usage
- Log into your standard Django Admin panel (e.g.,
/admin/). - Navigate to
/live-logs/in your browser. - Click Connect.
- Watch your server logs flow in real-time!
How it Works
The custom WebSocketLogHandler intercepts Python logs. Instead of blocking the main thread, it tosses the log payload to a daemon thread. The daemon thread safely uses async_to_sync to dispatch the JSON payload to the Redis Channel Layer. Finally, the Django Channels WebSocket consumer securely beams it to the authenticated frontend UI.
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 django_live_logs-0.1.2.tar.gz.
File metadata
- Download URL: django_live_logs-0.1.2.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c01162740f17823a87954a50a5446fad78d55d0fc67c822690effa7ab84d71
|
|
| MD5 |
e5206da2a1381d518ce99c70ce6c450a
|
|
| BLAKE2b-256 |
3ea96558005249a61bab851d5a6cca6c8a4b8b79f06e0d0be39855370d3b56f8
|
File details
Details for the file django_live_logs-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_live_logs-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ab254030d5a150f79fb9eb10ef77191749bf871cde18cc1e18abe3a1945d6b8
|
|
| MD5 |
968a276204ee5753df8cfe625107efd1
|
|
| BLAKE2b-256 |
112e38391fedfb99d946dbdfb32d5717fc9897fb4e196b200672f66120ad6e81
|