From 7341549f9b7d55e6697fa6464bddf64297ccc002 Mon Sep 17 00:00:00 2001 From: Ashwin Hegde Date: Fri, 27 Mar 2015 14:15:42 +0530 Subject: [PATCH] Updates consoles E.g. --- .../Console/{console.js => console-1.js} | 22 +++++++------- Kit/Session-3/Console/console-2.js | 30 +++++++++++++++++++ 2 files changed, 41 insertions(+), 11 deletions(-) rename Kit/Session-3/Console/{console.js => console-1.js} (77%) create mode 100644 Kit/Session-3/Console/console-2.js diff --git a/Kit/Session-3/Console/console.js b/Kit/Session-3/Console/console-1.js similarity index 77% rename from Kit/Session-3/Console/console.js rename to Kit/Session-3/Console/console-1.js index 7a8b367..554e0ba 100644 --- a/Kit/Session-3/Console/console.js +++ b/Kit/Session-3/Console/console-1.js @@ -4,7 +4,7 @@ * functions provided by most of the web browsers. * * How to run this example: - * 1. node console.js + * 1. node console-1.js * 2. See the message get displayed on prompt. */ @@ -14,35 +14,35 @@ */ console.log("Hi, My name is Ashwin Hegde"); -var designation = "Web Developer"; +var designation = "Sr. Software Engineer"; console.log("I am " + designation + " at Cybage Software Private Limited, Pune, HQ"); var experience = 2.6; -console.log("I have total %d of Experience", experience); // %d is for both Integer & Float. +console.log("I have total %d of Experience, excluding 10 months as freelancer", experience); // %d is for both Integer & Float. var languages = { "lang1": "JavaScript", - "lang2": "PHP", - "lang3": ".NET", - "lang4": "Java", + "lang2": "Go", + "lang3": "PHP", + "lang4": "Python", "lang5": "Ruby", - "lang6": "Python" -} + "lang6": "Java" +}; console.log("Printing output when used to print JSON Object via %s: ", languages); // %s for String console.log("Printing output when used to print JSON Object via %j: ", languages); // %j for JSON console.log("%s is Awesome.", "node"); /*** - * Same as console.log + * Same as console.log prints to stdout. */ console.info("Info: Information Message"); -console.warn("Warn: Warning Message"); /*** * Same as console.log but prints to stderr. */ -console.error("Error: Error Message") +console.error("Error: Error Message"); +console.warn("Warn: Warning Message"); /*** * console.time() will mark a time. diff --git a/Kit/Session-3/Console/console-2.js b/Kit/Session-3/Console/console-2.js new file mode 100644 index 0000000..6f11b9e --- /dev/null +++ b/Kit/Session-3/Console/console-2.js @@ -0,0 +1,30 @@ +/*** + * The goal of this file is to know about the console functions; + * Used for printing standard outputs and errors. Similar to the console object + * functions provided by most of the web browsers. + * + * How to run this example: + * 1. node console-2.js 1>debug.log 2>errors.log [This will truncate the file to a length of zero] + * OR 1. node console-2.js 1>>debug.log 2>>errors.log [This will append the messages] + * 2. See the debug.log and errors.log generated files. + */ + +/*** + * Prints to stdout. +*/ +console.log("Log"); + +/*** + * Same as console.log prints to stdout. +*/ +console.info("Info"); + +/*** + * Prints to stderr. +*/ +console.error("Error"); + +/*** + * Same as console.log prints to stderr. +*/ +console.warn("Warning");