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", "name": "@hibas123/logging",
"version": "2.1.4", "version": "2.1.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

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