'condition inside winston format

I want to create a html file using winston, where the text is colored according to information level (red for errors, blue for info, etc.) I wanted to add something like this: winston.format.printf( info => <div style="color: ${info.level} === error ? 'red' : 'green';">${info.timestamp} ${info.level}: ${info.message}<\div>, ),);

But of course it just prints the condition into the html like this:

2022-03-08T13:48:47.162Z info: this is info message 2022-03-08T13:48:47.164Z error: this is error message

so what I actually need is to plant the javascript condition into the html. Can this be done?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source