tslog
tslog copied to clipboard
Feature Request: Ability to add to root JSON keys
My end goal is to integrate with Datadog. In order to associate logs with requests, Datadog requires certain fields to be in the JSON object logged. I couldn't find a way to do this with tslog. prefix adds values to argumentsArray but I need to be able to add custom values and keys to the log object itself. Details on configuring logs for Datadog are here.
I also need this and came here looking for it. You can't fit everything you need into "requestId", thats just not going to fit every situation.
Prefix also isn't a very good abstraction. It might work fine for text logs, but for JSON, an array of "arguments" where everything has been stringified is pretty clunky. I absolutely expected to be able to modify the root level object, or at the very least an object called customFields: Record<any,any>
I can see that, thank you. This is going to be the main breaking change in V4, I am working on right now.
I've been working on a new, completely rewritten version (4.0). This version is way more flexible, and you can basically overwrite all the internal functionality, including the main Object, which opens endless opportunities for integrations. Can you give it a go and let me know if that solves your problem?
-
npm i tslog@next -
and run it with
node --enable-source-mapsor for TypeScriptnode --enable-source-maps --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm
Here is an example on how to use it: https://github.com/fullstack-build/tslog/blob/v4/tests/Nodejs/8_json_LogObj.test.ts#L14
V4 is released now, so I'm going to close this issue. Feel free to open a new one if V4 didn't solve it for you.
Here are the docs: tslog.js.org