Merge pull request #294 from YunoHost/highlight-warnings-errors-in-tools-logs

[enh] Highlight error/warnings/... in tools > logs
This commit is contained in:
Alexandre Aubin 2020-04-26 00:06:04 +02:00 committed by GitHub
commit adca9ed616
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,11 +137,19 @@
log.metadata.env = log.metadata.args log.metadata.env = log.metadata.args
} }
} }
c.view('tools/tools_log', { c.view('tools/tools_log', {
"log": log, "log": log,
"next_number": log.logs.length == number ? number * 10:false, "next_number": log.logs.length == number ? number * 10:false,
"locale": y18n.locale "locale": y18n.locale
}, function() { }, function() {
log = $("#main #log").html();
log = log.replace(/.*: ERROR - .*/g, function (match) { return '<span class="alert-danger">'+match+'</span>'});
log = log.replace(/.*: WARNING - .*/g, function (match) { return '<span class="alert-warning">'+match+'</span>'});
log = log.replace(/.*: SUCCESS - .*/g, function (match) { return '<span class="alert-success">'+match+'</span>'});
log = log.replace(/.*: INFO - .*/g, function (match) { return '<span class="alert-info">'+match+'</span>'});
$("#main #log").html(log);
// Configure behavior for the button to share log on Yunohost (it calls display --share) // Configure behavior for the button to share log on Yunohost (it calls display --share)
$('button[data-action="share"]').on("click", function() { $('button[data-action="share"]').on("click", function() {
c.api('GET', '/logs/display?path='+$(this).data('log-id')+'&share', {}, c.api('GET', '/logs/display?path='+$(this).data('log-id')+'&share', {},