2019-04-01 03:35:23 +00:00
|
|
|
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))
|
2019-04-01 03:35:23 +00:00
|
|
|
}
|
|
|
|
}
|