Log original request JSON



  • When serving locally (for development), I'd like to be able to log the request body sent to JSReport for render requests. Is there an easy way to log that? I've set up my local much like the example server code.

    const jsreport = require('jsreport')()
    const Config = require('./config');
    
    Config.init();
    
    if (process.env.JSREPORT_CLI) {
      // export jsreport instance to make it possible to use jsreport-cli
      module.exports = jsreport
    } else {
      jsreport.init().then(() => {
        // running
      }).catch((e) => {
        // error during startup
        console.error(e.stack)
        process.exit(1)
      })
    }
    


  • You can add this to your server.js

    jsreport.beforeRenderWorkerAllocatedListeners.add('logging', (req) => {
      jsreport.logger.info('input request ' + req.rawContent)
    })
    

Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.