start with syslog

This commit is contained in:
Christian Herzog
2020-03-05 20:50:36 +01:00
parent 69ba176990
commit 93dbaa516a
3 changed files with 76 additions and 87 deletions

View File

@@ -40,7 +40,6 @@ var commandHeader = 'squeezelite -b 500:2000 -d all=info ';
var pname, ver, otapct, otadsc; var pname, ver, otapct, otadsc;
var blockAjax = false; var blockAjax = false;
var blockFlashButton = false; var blockFlashButton = false;
var lastMsg = '';
var apList = null; var apList = null;
var selectedSSID = ""; var selectedSSID = "";
@@ -655,11 +654,11 @@ function refreshAPHTML(data){
} }
function getMessages() { function getMessages() {
$.getJSON("/messages.json", function(data) { $.getJSON("/messages.json?1", function(data) {
data.forEach(function(msg) { data.forEach(function(msg) {
var msg_age = msg["current_time"] - msg["sent_time"]; var msg_age = msg["current_time"] - msg["sent_time"];
var msg_time = new Date( ); var msg_time = new Date();
msg_time.setTime( msg_time .getTime() - msg_age ); msg_time.setTime( msg_time.getTime() - msg_age );
switch (msg["class"]) { switch (msg["class"]) {
case "MESSAGING_CLASS_OTA": case "MESSAGING_CLASS_OTA":
//message: "{"ota_dsc":"Erasing flash complete","ota_pct":0}" //message: "{"ota_dsc":"Erasing flash complete","ota_pct":0}"
@@ -681,16 +680,22 @@ function getMessages() {
case "MESSAGING_CLASS_STATS": case "MESSAGING_CLASS_STATS":
// for task states, check structure : task_state_t // for task states, check structure : task_state_t
var stats_data = JSON.parse(msg["message"]); var stats_data = JSON.parse(msg["message"]);
console.log(msg_time + " - Number of tasks on the ESP32: " + stats_data["ntasks"]); console.log(msg_time.toLocaleString() + " - Number of tasks on the ESP32: " + stats_data["ntasks"]);
var stats_tasks = stats_data["tasks"]; var stats_tasks = stats_data["tasks"];
console.log(msg_time + '\tname' + '\tcpu' + '\tstate'+ '\tminstk'+ '\tbprio'+ '\tcprio'+ '\tnum' ); console.log(msg_time.toLocaleString() + '\tname' + '\tcpu' + '\tstate'+ '\tminstk'+ '\tbprio'+ '\tcprio'+ '\tnum' );
stats_tasks.forEach(function(task) { stats_tasks.forEach(function(task) {
console.log(msg_time + '\t' + task["nme"] + '\t'+ task["cpu"] + '\t'+ task_state_t[task["st"]]+ '\t'+ task["minstk"]+ '\t'+ task["bprio"]+ '\t'+ task["cprio"]+ '\t'+ task["num"]); console.log(msg_time.toLocaleString() + '\t' + task["nme"] + '\t'+ task["cpu"] + '\t'+ task_state_t[task["st"]]+ '\t'+ task["minstk"]+ '\t'+ task["bprio"]+ '\t'+ task["cprio"]+ '\t'+ task["num"]);
}); });
break; break;
case "MESSAGING_CLASS_SYSTEM": case "MESSAGING_CLASS_SYSTEM":
showMessage(msg["message"], msg["type"],msg_age); showMessage(msg["message"], msg["type"],msg_age);
lastMsg = msg;
$("#syslogTable").append(
"<tr class='"+msg["type"]+"'>"+
"<td>"+msg_time.toLocaleString()+"</td>"+
"<td>"+msg["message"]+"</td>"+
"</tr>"
);
break; break;
default: default:
break; break;
@@ -703,6 +708,14 @@ function getMessages() {
console.log(thrownError); console.log(thrownError);
if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR'); if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR');
}); });
/*
Minstk is minimum stack space left
Bprio is base priority
cprio is current priority
nme is name
st is task state. I provided a "typedef" that you can use to convert to text
cpu is cpu percent used
*/
} }
function checkStatus(){ function checkStatus(){
RepeatCheckStatusInterval(); RepeatCheckStatusInterval();
@@ -924,7 +937,6 @@ function getConfig() {
function showMessage(message, severity, age=0) { function showMessage(message, severity, age=0) {
if (severity == 'MESSAGING_INFO') { if (severity == 'MESSAGING_INFO') {
$('#message').css('background', '#6af'); $('#message').css('background', '#6af');
} else if (severity == 'MESSAGING_WARNING') { } else if (severity == 'MESSAGING_WARNING') {
@@ -935,7 +947,6 @@ function showMessage(message, severity, age=0) {
$('#message').css('background', '#f00'); $('#message').css('background', '#f00');
} }
$('#message').html(message); $('#message').html(message);
$("#content").fadeTo("slow", 0.3, function() { $("#content").fadeTo("slow", 0.3, function() {
$("#message").show(500).delay(5000).hide(500, function() { $("#message").show(500).delay(5000).hide(500, function() {

View File

@@ -67,7 +67,7 @@
<a class="nav-link" data-toggle="tab" href="#tab-firmware">Firmware</a> <a class="nav-link" data-toggle="tab" href="#tab-firmware">Firmware</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-gpio">GPIO</a> <a class="nav-link" data-toggle="tab" href="#tab-syslog">Syslog</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-nvs">NVS editor</a> <a class="nav-link" data-toggle="tab" href="#tab-nvs">NVS editor</a>
@@ -190,7 +190,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div> <!-- wifi -->
<div class="tab-pane fade" id="tab-audio"> <div class="tab-pane fade" id="tab-audio">
<div id="audioout"> <div id="audioout">
@@ -240,72 +240,7 @@
<label class="custom-control-label" for="autoexec-cb"></label> <label class="custom-control-label" for="autoexec-cb"></label>
</div> </div>
<br /> <br />
</div> </div> <!-- audio -->
<div class="tab-pane fade" id="tab-gpio">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Signal</th>
<th scope="col">I2S pin</th>
<th scope="col">SPDIF pin</th>
</tr>
</thead>
<tbody id="gpioTable">
<tr>
<td>Bit clock</td>
<td>
<input type="text" class="form-control gpio" id="gpio-i2s-bc" maxlength="2" size="2">
</td>
<td>
<input type="text" class="form-control gpio" id="gpio-spdif-bc" maxlength="2" size="2">
</td>
</tr>
<tr>
<td>Word select</td>
<td>
<input type="text" class="form-control gpio" id="gpio-i2s-ws" maxlength="2" size="2">
</td>
<td>
<input type="text" class="form-control gpio" id="gpio-spdif-ws" maxlength="2" size="2">
</td>
</tr>
<tr>
<td>Data</td>
<td>
<input type="text" class="form-control gpio" id="gpio-i2s-data" maxlength="2" size="2">
</td>
<td>
<input type="text" class="form-control gpio" id="gpio-spdif-data" maxlength="2" size="2">
</td>
</tr>
</tbody>
</table>
<div class="buttons">
<input id="save-gpio" type="button" class="btn btn-success" value="Save" />
</div>
</div>
<div class="tab-pane fade" id="tab-nvs">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody id="nvsTable">
</tbody>
</table>
<div class="buttons">
<div id="boot-div">
<form id="reboot-form" action="/reboot.json" method="post" target="dummyframe">
<button id="reboot-button" type="submit" class="btn btn-primary">Reboot</button>
</form>
</div>
<input id="save-nvs" type="button" class="btn btn-success" value="Save" />
</div>
</div>
<div class="tab-pane fade" id="tab-firmware"> <div class="tab-pane fade" id="tab-firmware">
<div id="boot-div"> <div id="boot-div">
@@ -354,11 +289,48 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div> <!-- firmware -->
<div class="tab-pane fade" id="tab-syslog">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">Message</th>
</tr>
</thead>
<tbody id="syslogTable">
</tbody>
</table>
<div class="buttons">
<input id="clear-syslog" type="button" class="btn btn-danger btn-sm" value="Clear" />
</div>
</div> <!-- syslog -->
<div class="tab-pane fade" id="tab-nvs">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody id="nvsTable">
</tbody>
</table>
<div class="buttons">
<div id="boot-div">
<form id="reboot-form" action="/reboot.json" method="post" target="dummyframe">
<button id="reboot-button" type="submit" class="btn btn-primary">Reboot</button>
</form>
</div>
<input id="save-nvs" type="button" class="btn btn-success" value="Save" />
</div>
</div> <!-- nvs -->
<div class="tab-pane fade" id="tab-credits"> <div class="tab-pane fade" id="tab-credits">
<div class="jumbotron"> <div class="jumbotron">
<p><strong><a href="https://github.com/sle118/squeezelite-esp32">squeezelite-esp32</a></strong>, &copy; 2019, philippe44, sle118, daduke<br />Licensed under the GPL</p> <p><strong><a href="https://github.com/sle118/squeezelite-esp32">squeezelite-esp32</a></strong>, &copy; 2020, philippe44, sle118, daduke<br />Licensed under the GPL</p>
<p> <p>
This app would not be possible without the following libraries: This app would not be possible without the following libraries:
</p> </p>
@@ -377,7 +349,7 @@
<input type="checkbox" class="custom-control-input" id="show-nvs" checked="checked"> <input type="checkbox" class="custom-control-input" id="show-nvs" checked="checked">
<label class="custom-control-label" for="show-nvs"></label> <label class="custom-control-label" for="show-nvs"></label>
</div> </div>
</div> </div> <!-- credits -->
</div> </div>
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer> <footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe> <iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>

View File

@@ -212,12 +212,6 @@ input[type='text'], input[type='password'], textarea {
padding: 4px; padding: 4px;
} }
input.gpio {
width: 2em;
color: #000;
height: 1.8em;
}
.custom-switch { .custom-switch {
margin-left: 8px; margin-left: 8px;
} }
@@ -273,6 +267,18 @@ textarea#autoexec1, textarea#fwurl, div#upload {
width: 80%; width: 80%;
} }
table tr.MESSAGING_INFO {
background: #123;
}
table tr.MESSAGING_WARNING {
background: #330;
}
table tr.MESSAGING_ERROR {
background: #300;
}
input, textarea { input, textarea {
border-radius: 3px; border-radius: 3px;
border: 1px solid transparent; border: 1px solid transparent;