Compare commits

..

2 Commits

Author SHA1 Message Date
Fabian Stamm
b647b8fae6 Merge branch 'master' of https://git.stamm.me/OpenServer/Logging 2020-04-09 17:47:43 +02:00
Fabian Stamm
ce9742a20e Also adding prefix to browser console output 2020-03-21 21:13:46 +01:00
2 changed files with 146 additions and 134 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@hibas123/logging",
"version": "2.1.4",
"version": "2.1.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,11 +1,19 @@
import { ObservableInterface } from "@hibas123/utils";
import { Colors } from "./index";
import {
<<<<<<< HEAD
Adapter,
Message,
FormattedLine,
TerminalFormats,
FormatTypes
=======
Adapter,
Message,
FormattedLine,
TerminalFormats,
FormatTypes,
>>>>>>> facb7e7b403e1dfaa8790426259e6effb0618efb
} from "./types";
const browser = typeof window !== "undefined";
@ -15,7 +23,11 @@ export class ConsoleAdapter implements Adapter {
observable.subscribe(this.onMessage.bind(this));
}
<<<<<<< HEAD
flush() {}
=======
flush() {}
>>>>>>> facb7e7b403e1dfaa8790426259e6effb0618efb
// TODO: Check if required!
// private escape(text: string): string {
@ -136,16 +148,16 @@ export class ConsoleAdapter implements Adapter {
if (browser) {
let formats: string[] = [];
let text = lines
.map((line) => {
.map(line => {
let [t, fmts] = this.formatLine(line);
formats.push(...fmts);
return t;
return prefix + t;
})
.join("\n");
// console.log(formats);
console.log(text, ...formats);
} else {
lines.forEach((line) => {
lines.forEach(line => {
let [text] = this.formatLine(line);
console.log(prefix + text);
});