blob: ea319b122ef0cc08e6d7688a7ec4c2fe5885efc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
export type LogTag = "webrtc" | "ws" | "media" | "*"
const log_tag_color: { [key in LogTag]: string } = {
"*": "#FF0000",
webrtc: "#990099",
media: "#999900",
ws: "#009999"
}
// TODO maybe log time aswell
export function log(tag: LogTag, message: string, ...data: any[]) {
for (let i = 0; i < data.length; i++) {
const e = data[i];
if (e instanceof MediaStreamTrack) data[i] = `(${e.kind}) ${e.id}`
}
console.log(`%c[${tag}] ${message}`, "color:" + log_tag_color[tag], ...data);
}
|