-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from StreamsTech/error-reporting
Error reporting
- Loading branch information
Showing
13 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.db import models |
71 changes: 71 additions & 0 deletions
71
geonode/error_reporting/templates/error_reporting/error_reporting.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{% extends "site_base.html" %} | ||
{% load activity_tags social_tags i18n %} | ||
|
||
{% block title %}{% trans "Error Logs" %}{% endblock %} | ||
|
||
{% block body_outer %} | ||
<br> | ||
<h1>Error Logs</h1> | ||
{% if object_list %} | ||
<div class="table-responsive"> | ||
<table class="table table-bordered"> | ||
<tr> | ||
<th><b>{% trans "User Name" %}</b></th> | ||
<th><b>{% trans "Level" %}</b></th> | ||
{% comment %}<th><b>Custom Message</b></th>{% endcomment %} | ||
<th><b>{% trans "System Message" %}</b></th> | ||
<th><b>{% trans "Traceback" %}</b></th> | ||
<th><b>{% trans "Created Time" %}</b></th> | ||
</tr> | ||
{% for error in object_list %} | ||
<tr> | ||
<td>{{ error.logger_name }}</td> | ||
<td class="error-level">{{ error.level }}</td> | ||
{% comment %}<td>{{ error.custom_msg }}</td>{% endcomment %} | ||
<td>{{ error.msg }}</td> | ||
<td>{{ error.trace }}</td> | ||
<td>{{ error.create_datetime }}</td> | ||
|
||
</tr> | ||
{% endfor %} | ||
</table> | ||
</div> | ||
<div class="text-center"> | ||
<nav aria-label="Page navigation"> | ||
{% if is_paginated %} | ||
<ul class="pagination"> | ||
{% if page_obj.has_previous %} | ||
<li> | ||
<a href="/error/reporting/?page={{ page_obj.previous_page_number }}" aria-label="Previous"> | ||
<span aria-hidden="true"><i class="fa fa-angle-double-left" aria-hidden="true"></i></span> | ||
</a> | ||
|
||
</li> | ||
{% endif %} | ||
<li> | ||
<span> | ||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} | ||
</span> | ||
</li> | ||
{% if page_obj.has_next %} | ||
<li> | ||
<a href="/error/reporting/?page={{ page_obj.next_page_number }}" aria-label="Next"> | ||
<span aria-hidden="true"><i class="fa fa-angle-double-right" aria-hidden="true"></i></span> | ||
</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
{% endif %} | ||
</nav> | ||
</div> | ||
{% else %} | ||
<p>No Error Found!!! ☺</p> | ||
{% endif %} | ||
|
||
{% endblock %} | ||
|
||
{% block extra_head %} | ||
{% endblock %} | ||
|
||
{% block extra_script %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
from django.conf.urls import url, include | ||
|
||
from .views import ErrorReportingListView | ||
|
||
urlpatterns = [ | ||
|
||
url(r'^', ErrorReportingListView.as_view(), name='error_reporting'), | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from django.views.generic.list import ListView | ||
from django_db_logger.models import StatusLog | ||
from django.utils.html import format_html | ||
|
||
|
||
# Create your views here. | ||
class ErrorReportingListView(ListView): | ||
|
||
template_name = 'error_reporting/error_reporting.html' | ||
model = StatusLog | ||
paginate_by = 50 | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(ErrorReportingListView, self).get_context_data(**kwargs) | ||
|
||
""" | ||
CRITICAL = 50 | ||
FATAL = CRITICAL | ||
ERROR = 40 | ||
WARNING = 30 | ||
WARN = WARNING | ||
INFO = 20 | ||
DEBUG = 10 | ||
NOTSET = 0 | ||
""" | ||
|
||
error_object = { | ||
50: format_html( | ||
"<span style='color:{color}; font-weight:{weight}'>{msg}</span>", | ||
color='red', | ||
weight='bold', | ||
msg='CRITICAL' | ||
), | ||
40: format_html( | ||
"<span style='color:{color}; font-weight:{weight}'>{msg}</span>", | ||
color='red', | ||
weight='bold', | ||
msg='ERROR' | ||
), | ||
30: format_html( | ||
"<span style='color:{color}; font-weight:{weight}'>{msg}</span>", | ||
color='orange', | ||
weight='bold', | ||
msg='WARNING' | ||
), | ||
20: format_html( | ||
"<span style='color:{color}; font-weight:{weight}'>{msg}</span>", | ||
color='green', | ||
weight='bold', | ||
msg='INFO' | ||
), | ||
10: format_html( | ||
"<span style='color:{color}; font-weight:{weight}'>{msg}</span>", | ||
color='orange', | ||
weight='bold', | ||
msg='DEBUG' | ||
), | ||
0: format_html( | ||
"<span style='color:{color}; font-weight:{weight}'>{msg}</span>", | ||
color='green', | ||
weight='bold', | ||
msg='NOTSET' | ||
), | ||
} | ||
|
||
if context['object_list']: | ||
for error in context['object_list']: | ||
error.level = error_object[int(error.level)] | ||
|
||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters