tslog icon indicating copy to clipboard operation
tslog copied to clipboard

v4: Display defaultLogObj (ex: requestId)

Open poluxus opened this issue 2 years ago • 0 comments

I successively followed the RequestId section in the readme. I have now a requestId field in my logObj.

But if I try to overwrite formatLogObj to display the requestId in the console, I can't find the field/value.

Am i doing something wrong, is it not supported yet ? Or in other words, how to display requestId in the log.

I thought of having the default log as quiet and let a new transport do all the work but it seems a little overkill.

Edit: I finally succeed with

overwrite: {
    toLogObj(args, clonesLogObj) {
      const fullLogObj = { ...args, ...(clonesLogObj as ILogObjReqId)}
      args.unshift(clonesLogObj?.requestId)
      return fullLogObj    },

But it mutate args wich I don't really like. If someone has a better idea

poluxus avatar May 03 '23 13:05 poluxus