Add support for external loggers

This commit is contained in:
He4eT 2021-02-23 15:09:20 +05:00
commit d9ded0c3d6
3 changed files with 25 additions and 11 deletions

View file

@ -15,12 +15,18 @@ const noopHandlers = [
'setSend'
].reduce((acc, x) => ((acc[x] = noop), acc), {})
module.exports = handlers_ => {
const defaultLoggers = {
log: console.log,
warning: console.warn,
error: console.error
}
module.exports = (handlers_, loggers = defaultLoggers) => {
const handlers =
Object.assign({}, noopHandlers, handlers_)
const Dialog = new FakeDialog(handlers)
const GlkOte = new CheapGlkOte(handlers)
const Dialog = new FakeDialog(handlers, loggers)
const GlkOte = new CheapGlkOte(handlers, loggers)
const sendFn = GlkOte.sendFn.bind(GlkOte)