-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding Pino to global #1258
Comments
This is not a recommended practice. Sharing global state means it is indeterministic what the status of that state is. Basically, you must make sure the global state is built the same way always and is never mutated. At a minimum this makes testing difficult. More drastically, it can make the application behavior unpredictable and the code base difficult to maintain. See https://softwareengineering.stackexchange.com/a/148109 We highly recommend: lib/logger.js: const pino = require('pino')
const logger = pino({ /* whatever options */ })
module.exports = logger any_other_file_in_the_project.js: const log = require('./lib/logger')
log.info('logger loaded') This makes use of the require cache -- https://nodejs.org/en/knowledge/getting-started/what-is-require/ |
I would even recommend against using the global cache (for mostly the same reason. |
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. |
Is there is an issue if I call
pino
and add it to theglobal
so that I do not have to import it in every file and call it?I am a frontend dev!
The text was updated successfully, but these errors were encountered: