forked from Ajaxy/telegram-tt
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.html
More file actions
32 lines (32 loc) · 925 Bytes
/
log.html
File metadata and controls
32 lines (32 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Logs Viewer</title>
</head>
<body>
<input type="file" id="log" accept="application/json">
<script>
document.querySelector("#log").addEventListener('change', (e) => {
const { files } = e.target;
const file = files[0];
const json = new FileReader();
json.onload = (e) => {
const { result } = e.target;
const logs = JSON.parse(result);
logs.forEach((log) => {
const { level, args, date, } = log;
const dateStr = "[" + new Date(date).toLocaleTimeString("en-GB") + "] ";
if(args[0] && typeof args[0] === 'string' && args[0].startsWith("%")) {
args[0] = dateStr + args[0];
} else {
args.unshift(dateStr);
}
console[level](...args);
});
};
json.readAsText(file);
})
</script>
</body>
</html>