logux / server

Build your own Logux server or make a proxy between a WebSocket and an HTTP backend in any language

Home Page:https://logux.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reporter enhancement request

nevf opened this issue · comments

I am using reporter.logger in my server code which accepts ( action, meta, msg ) params. I'd like to include other Objects in the Bunyan log.

Could an optional object param be added after msg for this purpose. Or is there some other way I can do this.

Right now I am merging my object with meta, which is not ideal.

What exactly you want to change? :)

Or show your server and logger code.

As per my previous post I've written this simple function:

/** Display spec'd info using the Logux specified logger to the console.
 */
function debug_logger( action, meta, msg ){
    app.reporter.logger.info( { action: action, meta: jsome.getColoredString( meta ) }, msg || '' )
}

I'd like to be able to include other objects in the Bunyan log so something like:

function debug_logger( action, meta, msg, other_obj ){
    app.reporter.logger.info(  { action: action, meta: meta }, msg || '',  other_obj || {} )
or
    app.reporter.logger.info(  { action: action, meta: meta, other_obj: other_obj || {}  }, msg || '')
}

I hope that helps explain things.

Where and how do you use this debug_logger?

I call it in my server code which uses logux server. For example in app.channel( ..) I call

debug_logger( action, Object.assign( {}, meta, { params: params, creator: creator } ), 'app.channel()' )

so I can include params and creator in the Bunyan log. However it would be much better I could do something like:

debug_logger( action, meta, 'app.channel()', { params: params, creator: creator } )

or something like that.

In debug_logger you don't need any special support from Logux. Just write directly to Bunyan instance in server.reporter