loglevel-plugin-remote icon indicating copy to clipboard operation
loglevel-plugin-remote copied to clipboard

Custom request payload format

Open davidslaby opened this issue 3 years ago • 6 comments

Allows devs to customize payload in JSON format + README updated

davidslaby avatar Jul 19 '21 18:07 davidslaby

Tested by me - fully working solution

davidslaby avatar Jul 19 '21 18:07 davidslaby

@kutuluk @Looooopy @roblangridge could you check please? :)

Thanks in advance!

davidslaby avatar Jul 22 '21 15:07 davidslaby

Perhaps an option to turn off interpolation and export of the interpolate function would do the trick? Personally, all I wanted was to receive my args in the format funtion unchanged so that I could add some additional information in each log in JSON format, like:

const customJSON = (log, args) => ({ msg: log.message, additionalInformation: args, level: log.level.label, }); so that in the end I could receive something like this: { "logs":[ { "msg":"Error during parsing", "additionalInformation":{ "message":"InvalidTokenError: Invalid token specified: JSON.parse: unexpected character at line 1 column 1 of the JSON data", "parsed":"XD" }, "level":"error" } ] }

but that interpolation unfortunately mashed it all into a string...

Iorweth333 avatar Aug 09 '21 16:08 Iorweth333

Perhaps an option to turn off interpolation and export of the interpolate function would do the trick? Personally, all I wanted was to receive my args in the format funtion unchanged so that I could add some additional information in each log in JSON format, like:

const customJSON = (log, args) => ({ msg: log.message, additionalInformation: args, level: log.level.label, }); so that in the end I could receive something like this: { "logs":[ { "msg":"Error during parsing", "additionalInformation":{ "message":"InvalidTokenError: Invalid token specified: JSON.parse: unexpected character at line 1 column 1 of the JSON data", "parsed":"XD" }, "level":"error" } ] }

but that interpolation unfortunately mashed it all into a string...

Perhaps I don't understand your reply. My PR was about completely different thing, I need to send log in different format to remote not to add some information.

davidslaby avatar Aug 09 '21 16:08 davidslaby

oh, that was the point, pardon me then

Iorweth333 avatar Aug 09 '21 16:08 Iorweth333

oh, that was the point, pardon me then

It's okay, descriptions is too short. I'm sending that to logz.io and the format is determined by object. So there was not any option to send logs like objects not in array by default.

davidslaby avatar Aug 09 '21 17:08 davidslaby