pino
pino copied to clipboard
Can not get mixin to work, am I doing it wrong? Is it broken?
My code is below. const Pino = require('pino') ({ browser: { write: (o) => { loggerFunction(o) } }, level: "trace", // mixin is NOT working!!! mixin () { return { test: "42" } } })
It's not currently supported by the browser API. Would you like to send a PR?
I'm not sure what you mean by PR, but now that I know it isn't supported in the browser, I know how to proceed. I have a loggerFunction() function that sends the actual message to the logging server, so inside that function I'll add code to extend (if that's the right word) the msg string variable I pass in, to include the labels and values in object whose labels and values I wish to include.
Simply put: https://github.com/pinojs/pino/blob/master/browser.js does not have this functionality. Only the server-side version of pino implements it. Would you like to contribute this by sending a Pull Reques?
I very much appreciate the idea, but I'm a total newbie to Javascript. having started learning about two months ago. I feel like the casual weekend hiker who was just asked to give Everett a shot. Definitely not now. I have a lot of learning to do first.
Hey I may be interested in implementing this. Having looked at the code my understanding is that I will have to attach a mixin property here: https://github.com/pinojs/pino/blob/master/browser.js#L79
And then I will make sure to call the mixin somewhere inside the asObject
function here
https://github.com/pinojs/pino/blob/master/browser.js#L187
Preferably when we create the initial o
:
var o = Object.assign(mixin ? mixin() : {}, { time: ts, level: pino.levels.values[level] })
How is that sound?
is there anywhere else that the mixin
needs to be called?
@davidmarkclements is most familiar with the browser code. He might chime in?
Any progress?