-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.ts
More file actions
33 lines (25 loc) · 844 Bytes
/
log.ts
File metadata and controls
33 lines (25 loc) · 844 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
33
import * as colors from "https://deno.land/std@0.179.0/fmt/colors.ts";
let _debug = false;
export function setDebug(debug: boolean): void {
_debug = debug;
}
function timestamp() : string {
return colors.white(`${new Date().toLocaleString()} `);
}
export function info(...args: unknown[]): void {
console.log(timestamp(), colors.brightWhite(args.join(" ")));
}
export function trace(...args: unknown[]): void {
console.log(timestamp(), colors.cyan(args.join(" ")));
}
export function error(...args: unknown[]): void {
console.log(timestamp(), colors.brightRed(args.join(" ")));
}
export function debug(...args: unknown[]): void {
if (_debug) {
console.log(timestamp(), colors.green(args.join(" ")));
}
}
export function subproc(...args: unknown[]): void {
console.log(timestamp(), colors.yellow(args.join(" ")));
}