From 4aaac7cf876a0ddbb55ce7c903b88f751130e13c Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 10 Oct 2011 11:17:50 +0200 Subject: [PATCH] Log styling --- couchpotato/core/logger.py | 4 +-- couchpotato/core/plugins/log/main.py | 9 +------ couchpotato/core/plugins/log/static/log.css | 39 +++++++++++++++++++++++++++-- couchpotato/core/plugins/log/static/log.js | 15 ++++++++++- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/couchpotato/core/logger.py b/couchpotato/core/logger.py index a0494fb..0596dcd 100644 --- a/couchpotato/core/logger.py +++ b/couchpotato/core/logger.py @@ -11,9 +11,7 @@ class CPLog(): self.logger = logging.getLogger() try: - from couchpotato.environment import Env - if Env.doDebug(): - import color_logs + import color_logs except: pass diff --git a/couchpotato/core/plugins/log/main.py b/couchpotato/core/plugins/log/main.py index 059b304..25bb783 100644 --- a/couchpotato/core/plugins/log/main.py +++ b/couchpotato/core/plugins/log/main.py @@ -36,15 +36,8 @@ class Logging(Plugin): log = '' if current_path: - # Reverse f = open(current_path, 'r') - lines = [] - for line in f.readlines(): - lines.insert(0, line) - - log = '' - for line in lines: - log += line + log = f.read() return jsonified({ 'success': True, diff --git a/couchpotato/core/plugins/log/static/log.css b/couchpotato/core/plugins/log/static/log.css index 63abfc6..6a4eef5 100644 --- a/couchpotato/core/plugins/log/static/log.css +++ b/couchpotato/core/plugins/log/static/log.css @@ -1,9 +1,13 @@ .page.log .nav { display: block; text-align: center; - padding: 0; - margin: 40px 0 20px; + padding: 20px 0; + margin: 0; font-size: 20px; + position: fixed; + width: 960px; + bottom: 0; + background: #4E5969; } .page.log .nav li { @@ -28,3 +32,34 @@ font-size: 20px; 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; } + diff --git a/couchpotato/core/plugins/log/static/log.js b/couchpotato/core/plugins/log/static/log.js index 09ebed5..70be4c7 100644 --- a/couchpotato/core/plugins/log/static/log.js +++ b/couchpotato/core/plugins/log/static/log.js @@ -25,9 +25,11 @@ Page.Log = new Class({ 'nr': nr }, 'onComplete': function(json){ - self.log.set('html', '
'+json.log+'
'); + self.log.set('html', self.addColors(json.log)); self.log.removeClass('loading'); + new Fx.Scroll(window, {'duration': 0}).toBottom(); + var nav = new Element('ul.nav').inject(self.log, 'top'); for (var i = 0; i < json.total; i++) { 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, '') + text = text.replace(/\u001b\[36m\u001b\[36m/gi, '') + text = text.replace(/\u001b\[0m\u001b\[0m\n/gi, '') + text = text.replace(/\u001b\[0m\u001b\[0m/gi, '') + + return '' + text + ''; } }) \ No newline at end of file