mirror of
https://github.com/He4eT/cheap-glkote.git
synced 2026-05-05 08:57:25 +00:00
Add support for external loggers
This commit is contained in:
parent
d8af07c1be
commit
d9ded0c3d6
3 changed files with 25 additions and 11 deletions
12
src/index.js
12
src/index.js
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue