I am using Winston.js to log some information in a Javascript application. The problem is that the log level should be hidden in the printed log.
Instead of having something like this:
info: some pretty and cool log message
I need to have something like this:
some pretty and cool log message
I have a look at the Winston main page, but I did not find anything.
Scrabbling the unit test of the library, I found this one: Custom formatter. Basically, declaring a custom formatter for a log level, you can basically do everything you want with the text that will be write to the log.
To write the log message only without any log level information, redefine the formatter for a log in the following way.
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
level: 'info',
pattern: /info\:/,
formatter: function(params) {
return undefined !== params.message ? params.message : "";
}
})
]
});
The above example defines a console logger
that prints only the message
for the logs of level info
, without any additional information.
Hope it helps.