pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.21k stars 875 forks source link

Add information automatically inside log #376

Closed AlessandroMinoccheri closed 6 years ago

AlessandroMinoccheri commented 6 years ago

Good morning, I would like to know if is possible to add automatically more information inside log for example IP client address without add every time inside message string the IP address manually.

Example:

const pino = require('pino')();
pino.info('First log');
pino.info('Second log');

It will produce logs like this:

{"level":30,"time":"2018-03-26T08:10:13.634Z","msg":"data_attauale: 2018-03-26T08:10:13+00:00","pid":63,"hostname":"b90e328fb7d9","v":1, "ip":"100.100.100.100"}
{"level":30,"time":"2018-03-26T08:10:13.634Z","msg":"data_ora_vendita: 2018-02-22T17:00:00+00:00","pid":63,"hostname":"b90e328fb7d9","v":1, "ip":"100.100.100.100"}

Thanks

mcollina commented 6 years ago

You can create a child logger (https://getpino.io/#/docs/API?id=child) and add as many properties that you need.

AlessandroMinoccheri commented 6 years ago

Thanks a lot for the quick answer! I'll try it!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.