Added basic log page

This commit is contained in:
Ruud
2011-06-04 21:30:45 +02:00
parent 776a988fb4
commit e5bd1b9249
3 changed files with 56 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
from .main import Logging
def start():
return Logging()
config = []
+30
View File
@@ -0,0 +1,30 @@
from couchpotato.api import addApiView
from couchpotato.core.helpers.request import jsonified, getParam
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
class Logging(Plugin):
def __init__(self):
addApiView('logging.get', self.get)
def get(self):
nr = int(getParam('nr', 0))
path = '%s%s' % (Env.get('log_path'), '.%s' % nr if nr > 0 else '')
# Reverse
f = open(path, 'r')
lines = []
for line in f.readlines():
lines.insert(0, line)
log = ''
for line in lines:
log += line
return jsonified({
'success': True,
'log': log,
})
+20 -1
View File
@@ -3,6 +3,25 @@ Page.Log = new Class({
Extends: PageBase,
name: 'log',
title: 'Show recent logs.'
title: 'Show recent logs.',
indexAction: function(){
var self = this;
if(self.log) self.log.destroy();
self.log = new Element('div.log', {
'text': 'loading...'
}).inject(self.el)
Api.request('logging.get', {
'data': {
'nr': 0
},
'onComplete': function(json){
self.log.set('html', '<pre>'+json.log+'</pre>')
}
})
}
})