mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
8984 filter log list
This commit is contained in:
parent
d6a7ba1fbe
commit
3d7a5bfe91
@ -14,6 +14,7 @@ from core.forms import ManagedFileForm
|
|||||||
from core.models import Job
|
from core.models import Job
|
||||||
from core.tables import JobTable
|
from core.tables import JobTable
|
||||||
from dcim.models import Device, DeviceRole, Platform
|
from dcim.models import Device, DeviceRole, Platform
|
||||||
|
from extras.choices import LogLevelChoices
|
||||||
from extras.dashboard.forms import DashboardWidgetAddForm, DashboardWidgetForm
|
from extras.dashboard.forms import DashboardWidgetAddForm, DashboardWidgetForm
|
||||||
from extras.dashboard.utils import get_widget_class
|
from extras.dashboard.utils import get_widget_class
|
||||||
from netbox.constants import DEFAULT_ACTION_PERMISSIONS
|
from netbox.constants import DEFAULT_ACTION_PERMISSIONS
|
||||||
@ -1189,20 +1190,36 @@ class ScriptResultView(TableMixin, generic.ObjectView):
|
|||||||
tests = None
|
tests = None
|
||||||
table = None
|
table = None
|
||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
|
LOG_LEVEL_RANK = {
|
||||||
|
LogLevelChoices.LOG_DEFAULT: 0,
|
||||||
|
LogLevelChoices.LOG_DEBUG: 1,
|
||||||
|
LogLevelChoices.LOG_SUCCESS: 2,
|
||||||
|
LogLevelChoices.LOG_INFO: 3,
|
||||||
|
LogLevelChoices.LOG_WARNING: 4,
|
||||||
|
LogLevelChoices.LOG_FAILURE: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
log_level = 0
|
||||||
|
if 'log_level' in request.GET:
|
||||||
|
log_level = LOG_LEVEL_RANK.get(request.GET["log_level"], LogLevelChoices.LOG_DEFAULT)
|
||||||
|
|
||||||
if job.data:
|
if job.data:
|
||||||
if 'log' in job.data:
|
if 'log' in job.data:
|
||||||
if 'tests' in job.data:
|
if 'tests' in job.data:
|
||||||
tests = job.data['tests']
|
tests = job.data['tests']
|
||||||
|
|
||||||
for log in job.data['log']:
|
for log in job.data['log']:
|
||||||
index += 1
|
check_level = LOG_LEVEL_RANK.get(log.get('status'), LogLevelChoices.LOG_DEFAULT)
|
||||||
result = {
|
if check_level >= log_level:
|
||||||
'index': index,
|
index += 1
|
||||||
'time': log.get('time'),
|
result = {
|
||||||
'status': log.get('status'),
|
'index': index,
|
||||||
'message': log.get('message'),
|
'time': log.get('time'),
|
||||||
}
|
'status': log.get('status'),
|
||||||
data.append(result)
|
'message': log.get('message'),
|
||||||
|
}
|
||||||
|
data.append(result)
|
||||||
|
|
||||||
table = ScriptResultsTable(data, user=request.user)
|
table = ScriptResultsTable(data, user=request.user)
|
||||||
table.configure(request)
|
table.configure(request)
|
||||||
|
Loading…
Reference in New Issue
Block a user