Commit aa8a6826 authored by Mathieu Giraud's avatar Mathieu Giraud Committed by Vidjil Team
Browse files

controllers/admin.py, views/admin/*.html: display log files other than Vidjil ones

This adds a 'format' optional argument to db.call('admin/log').
parent 230f36ec
......@@ -53,13 +53,20 @@ def log():
lines = []
file = open(defs.DIR_LOG+request.vars["file"])
log_format = request.vars['format'] if 'format' in request.vars else ''
if "filter" not in request.vars :
request.vars["filter"] = ""
for row in reversed(file.readlines()) :
if vidjil_utils.filter(row, request.vars["filter"]) :
if not vidjil_utils.filter(row, request.vars["filter"]) :
continue
if not log_format: # == 'vidjil'
line = { 'mes': row, 'date': '', 'date2': '', 'user': '', 'type':'', 'file':''}
else:
# Parses lines such as
# [11889] 2015-02-01 12:01:28,367 INFO - default.py:312 1.23.45.67/user/Toto <Toto> xxxxx log message
# [11889] 2015-02-01 12:01:28,367 INFO - default.py:312 1.23.45.67 log message
......@@ -87,12 +94,13 @@ def log():
line["mes"] = vidjil_utils.log_links(line["mes"])
lines.append(line)
### Stores log line
lines.append(line)
if len(lines) >= 100 :
return dict(lines = lines)
if len(lines) >= 100 :
break
return dict(lines = lines)
return {'lines': lines, 'format': log_format}
## to use after change in the upload folder
def repair_missing_files():
......
......@@ -13,8 +13,8 @@
<hr>
</br>Vidjil server:
<a class="button" onclick="db.call('admin/log', {'file' : 'vidjil.log'} );">vidjil.log</a>
<a class="button" onclick="db.call('admin/log', {'file' : 'vidjil-debug.log'} );">debug.log</a>
<a class="button" onclick="db.call('admin/log', {'file' : 'vidjil.log', 'format': 'vidjil'} );">vidjil.log</a>
<a class="button" onclick="db.call('admin/log', {'file' : 'vidjil-debug.log', 'format': 'vidjil'} );">debug.log</a>
<a class="button" href="/admin/default/errors/vidjil">web2py tickets</a>
</br>Ngnix:
......
......@@ -7,7 +7,7 @@
<div class="db_block_left">
search
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}"
onchange="db.call('admin/log', {'file' : '{{=request.vars["file"]}}', 'filter' : this.value} )" >
onchange="db.call('admin/log', {'file' : '{{=request.vars["file"]}}', 'filter' : this.value, 'format': '{{=request.vars["format"]}}' } )" >
</div>
</div>
......@@ -17,22 +17,26 @@
<thead>
<tr>
{{ if format: }}
<td class="column_100"> date </td>
<td class="column_100"> </td>
<td class="column_200"> user </td>
<td class="column_100"> type </td>
<td class="column_100"> file </td>
{{ pass }}
<td> </td>
</tr>
</thead>
{{for line in lines :}}
<tr>
{{ if format: }}
<td> {{=line["date"]}} </td>
<td> {{=line["date2"]}} </td>
<td> {{=line["user"]}} </td>
<td> {{=line["type"]}} </td>
<td> {{=line["file"]}} </td>
{{ pass }}
<td> {{=XML(line["mes"])}} </td>
</tr>
{{pass}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment