messenger-req-log
v0.1.0
Published
Use `req.log` for logging (messenger-core)
Downloads
3
Readme
messenger-req-log
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)
Installation
$ npm install --save messenger-req-log
Usage
const MessengerLog = require('messenger-req-log')
function createMyBot(messenger) {
return messenger
.use(MessengerLog())
.use((message, context) => {
context.log.info('Hello, World!')
})
}
with Express or Restify
const app = require('express')()
const messenger = require('express-messenger')()
app.post('/',
require('body-parser').json(),
createMyBot(messenger)
)
with Micro
const messenger = require('micro-messenger')()
module.exports = createMyBot(messenger)
Ideas
- Create & use a child logger if the server’s logger has a
child()
function (like Bunyan does)
License
MIT © Andreas Pizsa