log viewer for web debugging

workspace
Brendan Howell 5 years ago
parent 2fc3b9e507
commit 873ab3b6a2

@ -14,6 +14,7 @@ class IhrApp(Bottle):
self.route("/", callback=self.index)
self.route("/config/<bureau>", callback=self.bureau_config)
self.route("/config/<bureau>", callback=self.bureau_config, method="POST")
self.route("/log/<bureau>", callback=self.bureau_log)
self.route('/static/<path:path>', callback=self.static)
self.bureaus = []
mpath = inspect.getfile(self.__class__)
@ -25,11 +26,14 @@ class IhrApp(Bottle):
templfile = os.path.join(self.tdir, "web_index.html")
out = """
<h3>The Screenless Office</h3>
<h4><em>Config Manager</em></h4>
<h4><em>Web Manager</em></h4>
<ul>
"""
for bureau in self.bureaus:
out += '<li>{0}\n'.format(bureau)
out += '<li><a href="/config/{0}">{0}</a></li>\n'.format(bureau)
out += '<li><a href="/log/{0}">{0}</a></li>\n'.format(bureau)
out += '</li>'
out += '<li><a href="/config/printers">Printers</a></li>\n'
out += '<li><a href="/config/mgmt">Management</a></li>\n'
@ -68,6 +72,19 @@ class IhrApp(Bottle):
cfgdata = cfg.read()
return template.render_unicode(msg=msg, bureau=bureau, cfgfile=cfgfile, mode=mode, cfgdata=cfgdata)
def bureau_log(self, bureau):
# display the current log file for a bureau
msg = ""
templfile = os.path.join(self.tdir, "web_logview.html")
template = mako.template.Template(filename=templfile, input_encoding='utf-8')
basedir = os.path.expanduser("~/.screenless")
logfile = os.path.join(basedir, cfgfile)
with open(logfile) as log:
logdata = log.read()
return template.render_unicode(msg=msg, bureau=bureau, logdata=logdata)
def register_bureau(self, bureau):
self.bureaus.append(bureau)

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>Screenless Office - log for ${bureau}</title>
<style type="text/css" media="screen">
#logview {
height: 40em;
width: 80em;
overflow: scroll;
}
</style>
</head>
<body>
<h3>The Screenless Office</h3>
<h4> edit config file <em>${cfgfile}</em></h4>
<div><a href="/">← Main</a></div>
<div id="logview">${logdata}</div>
<script>
var logDiv = document.getElementById("logview");
logDiv.scrollTop = objDiv.scrollHeight;
</script>
</body>
</html>
Loading…
Cancel
Save