Tuesday, 2 October 2018

node.js: console.groupEnd(): Decreases the indentation while logging

console.groupEnd()
Decreases indentation of subsequent lines by two spaces.

HelloWorld.js
console.group("User '%s' login failed", "Krishna");
console.group("Please retry after some time");
console.group("If you forgot the password, please retry");

console.groupEnd();
console.log("\nCalling groupEnd first time");
console.log("Good Morning");
console.log("Have a nice day");
console.log("Welocme to node.js programming");

console.groupEnd();
console.log("\nCalling groupEnd second time");
console.log("Good Morning");
console.log("Have a nice day");
console.log("Welocme to node.js programming");

console.groupEnd();
console.log("\nCalling groupEnd third time");
console.log("Good Morning");
console.log("Have a nice day");
console.log("Welocme to node.js programming");

console.groupEnd();
console.log("\nCalling groupEnd fourth time");
console.log("Good Morning");
console.log("Have a nice day");
console.log("Welocme to node.js programming");

Output
User 'Krishna' login failed
  Please retry after some time
    If you forgot the password, please retry

    Calling groupEnd first time
    Good Morning
    Have a nice day
    Welocme to node.js programming

  Calling groupEnd second time
  Good Morning
  Have a nice day
  Welocme to node.js programming

Calling groupEnd third time
Good Morning
Have a nice day
Welocme to node.js programming

Calling groupEnd fourth time
Good Morning
Have a nice day
Welocme to node.js programming


Previous                                                 Next                                                 Home

No comments:

Post a Comment