Also adding prefix to browser console output
This commit is contained in:
parent
675ec50139
commit
ce9742a20e
@ -1,3 +1,4 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 3
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hibas123/logging",
|
||||
"version": "2.1.4",
|
||||
"version": "2.1.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hibas123/logging",
|
||||
"version": "2.1.4",
|
||||
"version": "2.1.5",
|
||||
"description": "",
|
||||
"main": "out/index.js",
|
||||
"types": "out/index.d.ts",
|
||||
|
@ -1,6 +1,12 @@
|
||||
import { ObservableInterface } from "@hibas123/utils";
|
||||
import { Colors } from "./index";
|
||||
import { Adapter, Message, FormattedLine, TerminalFormats, FormatTypes } from "./types";
|
||||
import {
|
||||
Adapter,
|
||||
Message,
|
||||
FormattedLine,
|
||||
TerminalFormats,
|
||||
FormatTypes
|
||||
} from "./types";
|
||||
|
||||
const browser = typeof window !== "undefined";
|
||||
|
||||
@ -128,20 +134,21 @@ export class ConsoleAdapter implements Adapter {
|
||||
if (message.name) prefix = `[${message.name}]=>`;
|
||||
|
||||
if (browser) {
|
||||
|
||||
let formats: string[] = [];
|
||||
let text = lines.map(line => {
|
||||
let text = lines
|
||||
.map(line => {
|
||||
let [t, fmts] = this.formatLine(line);
|
||||
formats.push(...fmts);
|
||||
return t;
|
||||
}).join("\n");
|
||||
return prefix + t;
|
||||
})
|
||||
.join("\n");
|
||||
// console.log(formats);
|
||||
console.log(text, ...formats);
|
||||
} else {
|
||||
lines.forEach(line => {
|
||||
let [text] = this.formatLine(line);
|
||||
console.log(prefix + text);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user