Better logging

This commit is contained in:
AndyGrant committed 2018-06-10 14:11:41 -04:00
1 parent f8e344fe00
commit 7d63b6b917
11 files changed
+14 -39

No files matched your search

+2 -1
View File
@@ -7,10 +7,11 @@ from django.contrib.auth.models import User
class LogEvent(Model): class LogEvent(Model):
data = CharField(max_length=256) data = CharField(max_length=256)
author = CharField(max_length=64)
creation = DateTimeField(auto_now=True) creation = DateTimeField(auto_now=True)
def __str__(self): def __str__(self):
return "{0} : {1}".format(self.creation, self.data) return "{0} {1} : {2}".format(self.creation, self.author, self.data)
class Engine(Model): class Engine(Model):
+4
View File
@@ -32,6 +32,10 @@ table {
font-size: 20px; font-size: 20px;
} }
th, td {
border: 1px solid black;
}
th { th {
text-align: center; text-align: center;
padding: 4px 16px; padding: 4px 16px;
+5 -8
View File
@@ -43,7 +43,8 @@ def register(request):
# Log the registration # Log the registration
event = LogEvent() event = LogEvent()
event.data = 'Created user {0}'.format(request.POST['username']) event.data = 'Created an account'
event.author = request.POST['username']
event.save() event.save()
# Kick back to index # Kick back to index
@@ -128,11 +129,7 @@ def machines(request):
def eventLog(request): def eventLog(request):
# Build context dictionary for template # Build context dictionary for template
data = {'events': []} data = {'events': LogEvent.objects.all()}
for event in LogEvent.objects.all():
data['events'].append({
'data' : event.data,
'creation' : event.creation})
return render(request, 'eventLog.html', data) return render(request, 'eventLog.html', data)
@login_required @login_required
@@ -148,8 +145,8 @@ def newTest(request):
# Log the test creation # Log the test creation
event = LogEvent() event = LogEvent()
event.data = '{0} : Created {1} (id={2})'.format( event.data = 'Created Test {0} ({1})'.format(str(test), test.id)
request.user.username, str(test), test.id) event.author = request.user.username
event.save() event.save()
return HttpResponseRedirect('/index/') return HttpResponseRedirect('/index/')
+1 -5
View File
@@ -5,11 +5,7 @@
<head> <head>
<link rel="stylesheet" href="{% static 'style.css' %}"> <link rel="stylesheet" href="{% static 'style.css' %}">
<title> <title>OpenBench</title>
{% block title %}
OpenBench
{% endblock %}
</title>
</head> </head>
<body> <body>
{% if error %} {% if error %}
+2 -5
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %} {% extends "OpenBench/base.html" %}
{% block title %}
Event Log
{% endblock %}
{% block style %} {% block style %}
{% load static %} {% load static %}
{% endblock %} {% endblock %}
@@ -12,7 +8,8 @@ Event Log
<table> <table>
{% for event in events %} {% for event in events %}
<tr> <tr>
<td>{{event.creation}}</td> <td style='text-align:left'>{{event.creation}}</td>
<td style='text-align:left'>{{event.author}}</td>
<td style='text-align:left'>{{event.data}}</td> <td style='text-align:left'>{{event.data}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
-4
View File
@@ -2,10 +2,6 @@
{% load mytags %} {% load mytags %}
{% block title %}
Index
{% endblock %}
{% block content %} {% block content %}
<h2>Pending</h2> <h2>Pending</h2>
<table> <table>
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %} {% extends "OpenBench/base.html" %}
{% block title %}
Login
{% endblock %}
{% block style %} {% block style %}
{% load static %} {% load static %}
{% endblock %} {% endblock %}
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %} {% extends "OpenBench/base.html" %}
{% block title %}
New Testhttp://127.0.0.1:12345/index
{% endblock %}
{% block content %} {% block content %}
<form method="POST" action="/newTest/"> <form method="POST" action="/newTest/">
{% csrf_token %} {% csrf_token %}
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %} {% extends "OpenBench/base.html" %}
{% block title %}
Register
{% endblock %}
{% block style %} {% block style %}
{% load static %} {% load static %}
{% endblock %} {% endblock %}
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %} {% extends "OpenBench/base.html" %}
{% block title %}
Event Log
{% endblock %}
{% block style %} {% block style %}
{% load static %} {% load static %}
{% endblock %} {% endblock %}
BIN
View File
Binary file not shown.