Display newline characters in notification view

This commit is contained in:
Adarnof 2016-02-18 19:42:00 +00:00
parent 8697d075a8
commit 3d82dd84c9
2 changed files with 7 additions and 2 deletions

View File

@ -2,6 +2,8 @@ import logging
from django.contrib.auth.models import User
from .models import Notification
logger = logging.getLogger(__name__)
class NotificationHandler(logging.Handler):
def emit(self, record):
for user in User.objects.all():
@ -10,5 +12,8 @@ class NotificationHandler(logging.Handler):
notif.user = user
notif.title = "%s [%s:%s]" % (record.levelname, record.funcName, record.lineno)
notif.level = str([item[0] for item in Notification.LEVEL_CHOICES if item[1] == record.levelname][0])
notif.message = record.getMessage()
message = record.getMessage()
message = message + "\n\n"
message = message + record.exc_text
notif.message = message
notif.save()

View File

@ -13,7 +13,7 @@
<div class="col-lg-12">
<div class="panel panel-{{ notif.level }}">
<div class="panel-heading">{{ notif.timestamp }} {{ notif.title }}</div>
<div class="panel-body">{{ notif.message }}</div>
<div class="panel-body"><pre>{{ notif.message }}</pre></div>
</div>
</div>
</div>