Hi
I am using pino logger . Sometimes we need to get the attr we have to create an audit record.
Here my scenario
let pino = require('pino');
let p = pino({}).child({class: 'hello'});
p.info('hello');
console.log(p)
Is there any function to get the values of class we set for the child logger?
I think we should refactor https://github.com/pinojs/pino/blob/master/lib/tools.js#L198-L216 so that every logger has a new function chindings() to retrieve these. Would you like to send us a PR?
@mcollina : one small question I do not find any documentation about chindings function and its usage. I can see it attached to pino object
@abuzarhamza matteo is proposing a chindings function be added, whereas the Symbol(pino.chindings) property is private (as are all symbol properties) so does not require documentation.
If you do want to create a PR around this, please make sure benchmarks aren't negatively impacted (and post results)
Hi @davidmarkclements @mcollina
I have some free time and would like to spend it by helping out in open source projects. Before I create an unfinished PR I have some questions:
If you have something better for me to do just tell :)
@yellowbrickc cool!
Yes :)
So that’s explained here https://github.com/pinojs/pino/pull/433#discussion_r194711807 (gh is opening the comment, open up the resolved discussion)
In terms of the satirical part, bit of an obscure inside joke - the three core contributors (to varying degrees) feel that es6 classes were a bad move, and that avoiding classes (in JavaScript) leads to better design patterns in general. We prefer a functional plus prototypical approach, which recognizes how the language actually works. However for debugging and profiling purposes I wanted the logger instances to appear as “Pino” - this requires a constructor property. I could have used a function as the constructor but used an empty class, so a class syntax was used in pursuit of avoiding class syntax. This is a good example of why not to make obscure references in comments.
Thanks for the explanation, now it is obvious that the proto.js is still used ;) And yes, I'm aware of the different opinions regarding classes and node... (I think classes belong to OOP languages and node is none.)
Ok, I want to solve this tomorrow or on Monday.
I will also extend the tests but I'm not sure where here https://github.com/yellowbrickc/pino/blob/master/docs/api.md#logger should the documentation be extended.
I’d recommend to send a PR early.
I would document this after child().
This issue can be closed now.
Most helpful comment
This issue can be closed now.