hemerajs / hemera

🔬 Writing reliable & fault-tolerant microservices in Node.js https://hemerajs.github.io/hemera/
MIT License
806 stars 70 forks source link

Custom logging #21

Closed acehko closed 7 years ago

acehko commented 7 years ago

How could I log additional data like trace$ or request$? The context object is not passed to the logger

StarpTech commented 7 years ago

Hi @acehko we seperate it in categorys:

  1. Internal logging (just logging no context)
  2. Client/server lifecycle events.

If you want to log request$ or trace$ you can listen on events see Zipkin package as example.

e.g

hemera.on('onClientPostRequest', function (ctx) {
  let trace = ctx.trace$
  let request = ctx.request$

 ctx.log.info(trace)
 ctx.log.info(request)
 ......
})
acehko commented 7 years ago

@StarpTech Thanks, that's what I was looking for. I did see these events in the docs: https://github.com/hemerajs/hemera#get-events But they're a bit different. Looks like the words Server and Client are missing.

StarpTech commented 7 years ago

@acehko yes you're right I updated them some days ago.