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