luci-base: accept alternative logread location
[oweals/luci.git] / modules / luci-mod-status / htdocs / luci-static / resources / view / status / syslog.js
1 'use strict';
2 'require fs';
3 'require ui';
4
5 return L.view.extend({
6         load: function() {
7                 return Promise.all([
8                         L.resolveDefault(fs.stat('/sbin/logread'), null),
9                         L.resolveDefault(fs.stat('/usr/sbin/logread'), null)
10                 ]).then(function(stat) {
11                         var logger = stat[0] ? stat[0].path : stat[1] ? stat[1].path : null;
12
13                         return fs.exec_direct(logger, [ '-e', '^' ]).catch(function(err) {
14                                 ui.addNotification(null, E('p', {}, _('Unable to load log data: ' + err.message)));
15                                 return '';
16                         });
17                 });
18         },
19
20         render: function(logdata) {
21                 var loglines = logdata.trim().split(/\n/);
22
23                 return E([], [
24                         E('h2', {}, [ _('System Log') ]),
25                         E('div', { 'id': 'content_syslog' }, [
26                                 E('textarea', {
27                                         'id': 'syslog',
28                                         'style': 'font-size:12px',
29                                         'readonly': 'readonly',
30                                         'wrap': 'off',
31                                         'rows': loglines.length + 1
32                                 }, [ loglines.join('\n') ])
33                         ])
34                 ]);
35         },
36
37         handleSaveApply: null,
38         handleSave: null,
39         handleReset: null
40 });