This commit is contained in:
Dax Raad
2025-05-18 14:13:04 -04:00
parent bcd2fd68b7
commit 0e303e6508
12 changed files with 493 additions and 144 deletions

View File

@@ -2,16 +2,21 @@ export namespace Log {
export function create(tags?: Record<string, any>) {
tags = tags || {};
function build(message: any, extra?: Record<string, any>) {
const prefix = Object.entries({
...tags,
...extra,
})
.map(([key, value]) => `${key}=${value}`)
.join(" ");
return [prefix, message];
}
const result = {
info(message?: any, extra?: Record<string, any>) {
const prefix = Object.entries({
...tags,
...extra,
})
.map(([key, value]) => `${key}=${value}`)
.join(" ");
console.log(prefix, message);
return result;
console.log(...build(message, extra));
},
error(message?: any, extra?: Record<string, any>) {
console.error(...build(message, extra));
},
tag(key: string, value: string) {
if (tags) tags[key] = value;