An easy way to change the log level in runtime.
Project description
django-logger-panel
An easy way to change the log level in runtime
Installation
pip install django-logger-panel
Features
- List all active loggers .
- Change any logger level in run time.
- Change all logger levels at once.
- Display logger information.
Settings.py
INSTALLED_APPS
Add loggerpanel
to installed apps
INSTALLED_APPS = [
...
'django_logger_panel',
]
LOGGING
Make sure the root
has a handler
set at the LOGGING
dictionary in settings.py
, as described in the Django Documentation.
This is the root
logger
configuration and will allow all loggers
with no handler
to inherit it from the root
.
Example:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'console': {
'format': '%(asctime)s %(levelname)-8s %(name)-12s %(message)s',
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'console',
},
},
'root': {
'level': 'DEBUG',
'handlers': ['console'],
},
}
LOGGER_PANEL_BASE_URL
Optionally, change the default base url /loggers/
by setting the property LOGGER_PANEL_BASE_URL
.
This variable is not required.
LOGGER_PANEL_BASE_URL = "/another-path/"
urls.py
Add the django_logger_panel.urls
to the urlpatterns
.
urlpatterns = [
...
path("", include("django_logger_panel.urls")),
...
]
Screenshots
Logger Panel
Logger Details
REST API
List loggers
Curl Example:
curl http://localhost:8000/loggers/ -H 'Accept:application/json'
Response:
{
"log_levels": {
"CRITICAL": 50,
"ERROR": 40,
"WARNING": 30,
"INFO": 20,
"DEBUG": 10,
"NOTSET": 0
},
"loggers": [
{
"name": "_all_loggers_",
"level": {
"code": 0,
"name": "NOTSET"
},
"effectiveLevel": {
"code": 0,
"name": "NOTSET"
},
"parent": null
},
{
"name": "root",
"level": {
"code": 30,
"name": "WARNING"
},
"effectiveLevel": {
"code": 30,
"name": "WARNING"
},
"parent": null
},
{
"name": "django",
"level": {
"code": 20,
"name": "INFO"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "root"
},
{
"name": "django.db.backends",
"level": {
"code": 0,
"name": "NOTSET"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "django"
},
{
"name": "django.request",
"level": {
"code": 0,
"name": "NOTSET"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "django"
},
{
"name": "django.server",
"level": {
"code": 20,
"name": "INFO"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "django"
},
{
"name": "django.security.csrf",
"level": {
"code": 0,
"name": "NOTSET"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "django"
},
{
"name": "django.db.backends.schema",
"level": {
"code": 0,
"name": "NOTSET"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "django.db.backends"
}
]
}
Return a single logger
Curl Example:
curl http://localhost:8000/loggers/django.db.backends -H 'Accept:application/json'
Response:
{
"name": "django.db.backends",
"level": {
"code": 0,
"name": "NOTSET"
},
"effectiveLevel": {
"code": 20,
"name": "INFO"
},
"parent": "django"
}
Change logger level
Curl Example:
curl -X POST http://localhost:8000/loggers/django.db.backends -d '{"logger_level": "DEBUG"}'
Response:
{
"name": "django.db.backends",
"level": {
"code": 10,
"name": "DEBUG"
},
"effectiveLevel": {
"code": 10,
"name": "DEBUG"
},
"parent": "django"
}
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
Built Distribution
Hashes for django-logger-panel-0.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4675729447e8ccc83be06352b465d707a791b6cd741d322656ac8d4acd5c9336 |
|
MD5 | faad5b71be2824ae0821d20e9df035f3 |
|
BLAKE2b-256 | 677a0e2adb4667fbcf4c4d86fe6fe4de65b821ef520b08b71e1564545f000c35 |
Hashes for django_logger_panel-0.1.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 702f1c17c9fc30aec07aac782bbe9a2ac90de03fad6c6a52b38e80bbffef79ef |
|
MD5 | ba9acd470cafd39975575fb67668fe1c |
|
BLAKE2b-256 | 5b985b9399b342a223e9d831919e4c24ebfd61e1367bd2e7b208a2f443bdc9a9 |