Use your web server’s request logger in your bot (
messenger-core
plugin)
This plugin will output your Bot’s log messages to the web server’s logger. Just use context.log[info|debug|error]
as usual and benefit from the web server’s log configuration (log levels, log targets, etc)
$ npm install --save messenger-req-log
const MessengerLog = require('messenger-req-log')
function createMyBot(messenger) {
return messenger
.use(MessengerLog())
.use((message, context) => {
context.log.info('Hello, World!')
})
}
const app = require('express')()
const messenger = require('express-messenger')()
app.post('/',
require('body-parser').json(),
createMyBot(messenger)
)
const messenger = require('micro-messenger')()
module.exports = createMyBot(messenger)
- Create & use a child logger if the server’s logger has a
child()
function (like Bunyan does)
MIT © Andreas Pizsa