singhsanket143 / Flights-Service

38 stars 18 forks source link

Feature #13: Winston library, change the log format so as to display t… #14

Open TusharWatts opened 1 year ago

TusharWatts commented 1 year ago

13

While logging, now we can log the additional parameters along with the message and severity level. For example,

app.listen(ServerConfig.PORT, () => { console.log('Successfully started the server on PORT : ${ServerConfig.PORT}'); Logger.error('Checking error logging', {msg: 'Something went wrong'}) });

Now, along with the message, it will also be able to log the additional parameters (or the meta data) So, instead of log output:

Screenshot 2023-06-05 210804

We will be able to log the meta data as follows:

Untitled232

We can pass any number of additional meta data, it will be able to log it in a stringify fashion

TusharWatts commented 1 year ago

In the printf() function, we can fetch the additional parameters (meta data) inside the 'info' parameter as a Symbol key. It will return as an array, then we can stringify it so as to render to the logs.