Logging/src/consolewriter.ts

19 lines
551 B
TypeScript
Raw Normal View History

import { ObservableInterface } from "@hibas123/utils";
import { Colors } from "./index";
import { Adapter, LoggingTypes, Message } from "./types";
export class ConsoleWriter implements Adapter {
init(observable: ObservableInterface<Message>) {
observable.subscribe(this.onMessage.bind(this));
}
flush() { }
onMessage(message: Message) {
let lines = message.text.formatted;
let name = "";
if (message.name) name = `[${message.name}]=>`;
2019-04-02 23:55:04 +00:00
lines.forEach(line => console.log(name + line + Colors.Reset))
}
}