mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
Show realtime debug log in WebUI #71
This commit is contained in:
@@ -14,6 +14,54 @@ const server = express()
|
||||
const es_port = 3090
|
||||
const ES_ENDPOINT_ROOT = '/es/'
|
||||
|
||||
// LOG
|
||||
const LOG_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'logSettings'
|
||||
const log_settings = {
|
||||
level: 6,
|
||||
}
|
||||
|
||||
const FETCH_LOG_ENDPOINT = REST_ENDPOINT_ROOT + 'fetchLog'
|
||||
const fetch_log = {
|
||||
events: [
|
||||
{
|
||||
time: '000+00:00:00.001',
|
||||
level: 3,
|
||||
name: 'system',
|
||||
message: 'this is message 3',
|
||||
},
|
||||
{
|
||||
time: '000+00:00:00.002',
|
||||
level: 4,
|
||||
name: 'system',
|
||||
message: 'this is message 4',
|
||||
},
|
||||
{
|
||||
time: '000+00:00:00.002',
|
||||
level: 5,
|
||||
name: 'system',
|
||||
message: 'this is message 5',
|
||||
},
|
||||
{
|
||||
time: '000+00:00:00.002',
|
||||
level: 6,
|
||||
name: 'system',
|
||||
message: 'this is message 6',
|
||||
},
|
||||
{
|
||||
time: '000+00:00:00.002',
|
||||
level: 7,
|
||||
name: 'emsesp',
|
||||
message: 'this is message 7',
|
||||
},
|
||||
{
|
||||
time: '000+00:00:00.002',
|
||||
level: 8,
|
||||
name: 'mqtt',
|
||||
message: 'this is message 8',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// NTP
|
||||
const NTP_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'ntpStatus'
|
||||
const NTP_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'ntpSettings'
|
||||
@@ -703,6 +751,21 @@ const emsesp_devicedata_3 = {
|
||||
data: [],
|
||||
}
|
||||
|
||||
// LOG
|
||||
app.get(FETCH_LOG_ENDPOINT, (req, res) => {
|
||||
res.json(fetch_log)
|
||||
})
|
||||
app.get(LOG_SETTINGS_ENDPOINT, (req, res) => {
|
||||
res.json(log_settings)
|
||||
})
|
||||
app.post(LOG_SETTINGS_ENDPOINT, (req, res) => {
|
||||
console.log('New log level is ' + req.body.level)
|
||||
const data = {
|
||||
level: req.body.level,
|
||||
}
|
||||
res.json(data)
|
||||
})
|
||||
|
||||
// NETWORK
|
||||
app.get(NETWORK_STATUS_ENDPOINT, (req, res) => {
|
||||
res.json(network_status)
|
||||
@@ -943,7 +1006,8 @@ const streamLog = (req, res) => {
|
||||
|
||||
const data = {
|
||||
time: '000+00:00:00.000',
|
||||
level: 4,
|
||||
level: 3,
|
||||
name: 'system',
|
||||
message: 'this is message #' + count,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user