Skip to content

📋 Use your web server’s request logger in your bot (`messenger-core` plugin)

License

Notifications You must be signed in to change notification settings

messengerjs/messenger-req-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage NPM version Greenkeeper badge

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

About

📋 Use your web server’s request logger in your bot (`messenger-core` plugin)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published