Tuesday, 2 October 2018

node.js: console.warn([data][, ...args]): Log warning message

console.warn([data][, ...args])
Prints the message to stderr with new line. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values.

HelloWorld.js
console.warn("User '%s' login failed", "Krishna");

Output
User 'Krishna' login failed

If formatting elements (e.g. %s, %d etc.,) are not found in the first string then util.inspect() is called on each argument and the resulting string values are concatenated.

HelloWorld.js
console.warn("User login failed","Krishna","Maximum attempts:",3);

Output
User login failed Krishna Maximum attempts: 3


Previous                                                 Next                                                 Home

No comments:

Post a Comment