sync
This commit is contained in:
parent
bcd2fd68b7
commit
0e303e6508
12 changed files with 493 additions and 144 deletions
0
js/src/util/event.ts
Normal file
0
js/src/util/event.ts
Normal 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue