You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use Pino in TypeScript, you can follow these steps:
Install the Pino library and its corresponding types:
npm install pino @types/pino
Import the necessary modules in your TypeScript file:
importpinofrom'pino';
Create a logger instance with the desired configuration:
constlogger=pino({level: 'info',// Set the log level (e.g., info, error, debug)redact: ['token'],// Specify properties to redact (e.g., token)prettyPrint: true,// Enable pretty-printing of logs (optional)});
In the above example, we're using the level option to set the log level. The redact option is used to specify properties to redact from log messages (e.g., "token"). You can customize these options based on your logging requirements.
Use the logger instance to log your token:
consttoken='mySecretToken123';logger.info({ token },'Received a token');
In this example, we're using the logger.info method to log the token. The token is passed as a property in the log object ({ token }).
Pino provides various features and options to further customize your logging experience. You can explore Pino's documentation (https://github.com/pinojs/pino) to learn more about its capabilities and how to adapt it to your specific use case.
The text was updated successfully, but these errors were encountered:
dayo09
changed the title
Print token as asterisks
Redact log
Jul 20, 2023
What?
Let's convert token printed on the console as asterisks for the sake of security.
(redact means to remove words or information from a text before it is printed or made available to the public)
How?
Use winston library(deprecated)Use pino library (MIT license, published 2 months ago)
https://www.npmjs.com/package/pino
The text was updated successfully, but these errors were encountered: