mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add test for long log messages
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
// used to simulate
|
||||||
|
// - file uploads
|
||||||
|
// - EventSource (SSE) for log messages
|
||||||
import formidable from 'formidable';
|
import formidable from 'formidable';
|
||||||
|
|
||||||
function pad(number) {
|
function pad(number) {
|
||||||
@@ -99,15 +102,21 @@ export default () => {
|
|||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
|
let message = 'message #' + count;
|
||||||
|
if (count % 6 == 1) {
|
||||||
|
message +=
|
||||||
|
' with a long message that will be wrapped, to see if it stays one a single line';
|
||||||
|
}
|
||||||
const data = {
|
const data = {
|
||||||
t: new Date().toISOString(),
|
t: new Date().toISOString(),
|
||||||
l: 3 + (count % 6),
|
l: 3 + (count % 6),
|
||||||
i: count,
|
i: count,
|
||||||
n: 'system',
|
n: 'system',
|
||||||
m: 'message #' + count++
|
m: message
|
||||||
};
|
};
|
||||||
|
count++;
|
||||||
res.write(`data: ${JSON.stringify(data)}\n\n`);
|
res.write(`data: ${JSON.stringify(data)}\n\n`);
|
||||||
}, 1000);
|
}, 800);
|
||||||
|
|
||||||
// if client closes connection
|
// if client closes connection
|
||||||
res.on('close', () => {
|
res.on('close', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user