actions-test/src/sys/log.ts

41 lines
975 B
TypeScript
Raw Normal View History

2023-02-28 14:44:10 +01:00
export const debug = (name: string, ...args: any[]) => {
if(!global.debug)return;
console.log(
"\x1b[33m%s\x1b[0m"+
"\x1b[1m\x1b[32m%s\x1b[0m",
(new Date()).toLocaleString(),
` [${name}]:`,
...args
);
};
export const log = (name: string, ...args: string[]) => {
console.log(
"\x1b[33m%s\x1b[0m"+
"\x1b[1m\x1b[36m%s\x1b[0m",
(new Date()).toLocaleString(),
` [${name}]:`,
...args
);
};
export const warn = (name: string, ...args: any[]) => {
console.warn(
"\x1b[33m%s\x1b[0m"+
"\x1b[1m\x1b[36m%s\x1b[0m",
(new Date()).toLocaleString(),
` [${name}]:`,
...args
);
};
export const error = (name: string, ...args: any[]) => {
console.error(
"\x1b[33m%s\x1b[0m"+
"\x1b[1m\x1b[41m%s\x1b[0m\x1b[41m",
(new Date()).toLocaleString()+" ",
`[${name}]:`,
...args,
"\x1b[0m"
);
};