Browse Source

Log styling

pull/51/merge
Ruud 14 years ago
parent
commit
4aaac7cf87
  1. 4
      couchpotato/core/logger.py
  2. 9
      couchpotato/core/plugins/log/main.py
  3. 39
      couchpotato/core/plugins/log/static/log.css
  4. 15
      couchpotato/core/plugins/log/static/log.js

4
couchpotato/core/logger.py

@ -11,9 +11,7 @@ class CPLog():
self.logger = logging.getLogger() self.logger = logging.getLogger()
try: try:
from couchpotato.environment import Env import color_logs
if Env.doDebug():
import color_logs
except: except:
pass pass

9
couchpotato/core/plugins/log/main.py

@ -36,15 +36,8 @@ class Logging(Plugin):
log = '' log = ''
if current_path: if current_path:
# Reverse
f = open(current_path, 'r') f = open(current_path, 'r')
lines = [] log = f.read()
for line in f.readlines():
lines.insert(0, line)
log = ''
for line in lines:
log += line
return jsonified({ return jsonified({
'success': True, 'success': True,

39
couchpotato/core/plugins/log/static/log.css

@ -1,9 +1,13 @@
.page.log .nav { .page.log .nav {
display: block; display: block;
text-align: center; text-align: center;
padding: 0; padding: 20px 0;
margin: 40px 0 20px; margin: 0;
font-size: 20px; font-size: 20px;
position: fixed;
width: 960px;
bottom: 0;
background: #4E5969;
} }
.page.log .nav li { .page.log .nav li {
@ -28,3 +32,34 @@
font-size: 20px; font-size: 20px;
padding: 50px; padding: 50px;
} }
.page.log .container {
padding: 30px 0 60px;
overflow: hidden;
}
.page.log .container span {
float: left;
width: 86%;
line-height: 150%;
padding: 3px 1%;
border-top: 1px solid rgba(255, 255, 255, 0.2);
font-size: 11px;
font-family: Lucida Console, Monaco, Nimbus Mono L;
}
.page.log .container .error {
color: #FFA4A4;
white-space: pre-wrap;
}
.page.log .container .debug { color: lightgrey; }
.page.log .container .time {
clear: both;
width: 11%;
color: lightgrey;
padding: 3px 0;
}
.page.log .container .time:last-child { display: none; }

15
couchpotato/core/plugins/log/static/log.js

@ -25,9 +25,11 @@ Page.Log = new Class({
'nr': nr 'nr': nr
}, },
'onComplete': function(json){ 'onComplete': function(json){
self.log.set('html', '<pre>'+json.log+'</pre>'); self.log.set('html', self.addColors(json.log));
self.log.removeClass('loading'); self.log.removeClass('loading');
new Fx.Scroll(window, {'duration': 0}).toBottom();
var nav = new Element('ul.nav').inject(self.log, 'top'); var nav = new Element('ul.nav').inject(self.log, 'top');
for (var i = 0; i < json.total; i++) { for (var i = 0; i < json.total; i++) {
new Element('li', { new Element('li', {
@ -57,6 +59,17 @@ Page.Log = new Class({
} }
}); });
},
addColors: function(text){
var self = this;
text = text.replace(/\u001b\[31m\u001b\[31m/gi, '</span><span class="error">')
text = text.replace(/\u001b\[36m\u001b\[36m/gi, '</span><span class="debug">')
text = text.replace(/\u001b\[0m\u001b\[0m\n/gi, '</span><span class="time">')
text = text.replace(/\u001b\[0m\u001b\[0m/gi, '</span><span>')
return '<span class="time">' + text + '</span>';
} }
}) })
Loading…
Cancel
Save