Reconnect SSE connection if we miss heartbeats for 30 seconds
Some checks failed
/ golint (push) Failing after 10s
Some checks failed
/ golint (push) Failing after 10s
Issue: #11
This commit is contained in:
parent
03d40774cb
commit
614f4d274e
2 changed files with 52 additions and 4 deletions
22
ts/log.ts
Normal file
22
ts/log.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// log.ts
|
||||
const pageLoadTime = performance.now();
|
||||
|
||||
function getTimestamp(): string {
|
||||
const elapsed = performance.now() - pageLoadTime;
|
||||
|
||||
const hours = Math.floor(elapsed / 3600000);
|
||||
const minutes = Math.floor((elapsed % 3600000) / 60000);
|
||||
const seconds = Math.floor((elapsed % 60000) / 1000);
|
||||
|
||||
return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
export const log = {
|
||||
info(...args: any[]): void {
|
||||
console.log(`[${getTimestamp()}]`, ...args);
|
||||
},
|
||||
|
||||
error(...args: any[]): void {
|
||||
console.error(`[${getTimestamp()}]`, ...args);
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue