Enable filtering by debug and automatic scroll to bottom
This commit is contained in:
parent
71c097e578
commit
cc54bb6469
@ -3,16 +3,51 @@
|
|||||||
<h1 class="DAU-heading">Config</h1>
|
<h1 class="DAU-heading">Config</h1>
|
||||||
<p class="lead">Discord-auto-upload logs</p>
|
<p class="lead">Discord-auto-upload logs</p>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm">
|
||||||
|
<button type="button" onClick="debug=1; get_logs();" class="btn btn-primary">all logs</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm">
|
||||||
|
<button type="button" onClick="debug=0; get_logs();" class="btn btn-primary">no debug</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm">
|
||||||
|
<button type="button" id="scroll-button" onClick="toggle_scroll();" class="btn btn-primary">disable auto-scroll</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<pre id="logs" class="text-left pre-scrollable">
|
<pre id="logs" class="text-left pre-scrollable">
|
||||||
</pre>
|
</pre>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
var debug = 0;
|
||||||
|
var scrl = true;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.ajax({ method: 'get', url: '/rest/logs'})
|
get_logs();
|
||||||
.done(function(data) {
|
setInterval(function() { get_logs(); }, 1000);
|
||||||
console.log(data);
|
});
|
||||||
$('#logs').text(data);
|
|
||||||
});
|
function toggle_scroll() {
|
||||||
});
|
scrl = !scrl;
|
||||||
|
if (scrl) {
|
||||||
|
$('#scroll-button').text('disable auto-scroll');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#scroll-button').text('auto-scroll');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_logs() {
|
||||||
|
$.ajax({ method: 'get', url: '/rest/logs', data: { debug : debug }})
|
||||||
|
.done(function(data) {
|
||||||
|
$('#logs').text(data);
|
||||||
|
console.log('scrl is ', scrl);
|
||||||
|
if (scrl) {
|
||||||
|
$('#logs').scrollTop(10000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -274,8 +274,17 @@ func getSetExclude(w http.ResponseWriter, r *http.Request) {
|
|||||||
func getLogs(w http.ResponseWriter, r *http.Request) {
|
func getLogs(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
|
||||||
|
showDebug := false
|
||||||
|
debug, present := r.URL.Query()["debug"]
|
||||||
|
if present && len(debug[0]) > 0 && debug[0] != "0" {
|
||||||
|
showDebug = true
|
||||||
|
}
|
||||||
|
|
||||||
text := ""
|
text := ""
|
||||||
for _, log := range daulog.LogEntries {
|
for _, log := range daulog.LogEntries {
|
||||||
|
if !showDebug && log.Type == daulog.LogTypeDebug {
|
||||||
|
continue
|
||||||
|
}
|
||||||
text = text + fmt.Sprintf(
|
text = text + fmt.Sprintf(
|
||||||
"%-6s %-19s %s\n", log.Type, log.Timestamp.Format("2006-01-02 15:04:05"), log.Entry,
|
"%-6s %-19s %s\n", log.Type, log.Timestamp.Format("2006-01-02 15:04:05"), log.Entry,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user