From e1ed12b00be4a14b6d21fa894a4407589d4497f3 Mon Sep 17 00:00:00 2001 From: Elias Hantula Date: Mon, 30 Oct 2017 16:02:14 -0400 Subject: [PATCH 1/4] verify package --- .gitignore | 1 + git.ignore | 0 index.js | 11 +++++++++ lib/logger.js | 0 package-lock.json | 62 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 26 ++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 .gitignore create mode 100644 git.ignore create mode 100644 index.js create mode 100644 lib/logger.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30bc162 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/git.ignore b/git.ignore new file mode 100644 index 0000000..e69de29 diff --git a/index.js b/index.js new file mode 100644 index 0000000..d393421 --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +const _ = require('lodash'); +const chalk = require('chalk') +const log = console.log; +var arr = [1,2,3] + + +_.each(arr, function(number){ + +log(chalk.blue(number)); +}) +log(chalk.blue("Hello world!")) \ No newline at end of file diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..e69de29 diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..19e9849 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,62 @@ +{ + "name": "assignment_node_hello_world", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "requires": { + "color-convert": "1.9.0" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "color-convert": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "requires": { + "has-flag": "2.0.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..812c091 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "assignment_node_hello_world", + "version": "1.0.0", + "description": "assignment_node_hello_world ===========================", + "main": "index.js", + "directories": { + "lib": "lib" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/eliashantula/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/eliashantula/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/eliashantula/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.3.0", + "lodash": "^4.17.4" + } +} From 81f7abbde8d72692f4c706f09224d72383c5ff99 Mon Sep 17 00:00:00 2001 From: Elias Hantula Date: Tue, 31 Oct 2017 12:54:49 -0400 Subject: [PATCH 2/4] logger color --- index.js | 14 +++++++++----- lib/logger.js | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index d393421..2e044b8 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,15 @@ const _ = require('lodash'); const chalk = require('chalk') -const log = console.log; -var arr = [1,2,3] - +var logger = require('./lib/logger') +var arr = [1,2,3]; _.each(arr, function(number){ -log(chalk.blue(number)); +console.log(chalk.blue(number)); }) -log(chalk.blue("Hello world!")) \ No newline at end of file +console.log(chalk.blue("Hello world!")); + + +logger.log("testing", "INFO") +logger.log("testing", "WARNING") +logger.log("testing", "ERROR") diff --git a/lib/logger.js b/lib/logger.js index e69de29..532cf9c 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -0,0 +1,25 @@ +chalk = require('chalk') +var logger = { + log: function(message,level) { +if (level === "INFO") { + this.info(message) } + else if (level === "WARNING") { + this.warning(message) + } else if (level ==="ERROR") { + this.error(message) + }; +}, + info: function(message) { + console.log(chalk.blue(message + " INFO level")); + +}, + warning: function(message){ + console.log(chalk.yellow(message + " WARNING level")); +}, + + error: function(message) { + console.log(chalk.red(message + " ERROR level")); +} +}; + +module.exports = logger \ No newline at end of file From 031faebab649ea29493281dc50fb4b4fc0246018 Mon Sep 17 00:00:00 2001 From: Elias Hantula Date: Tue, 31 Oct 2017 13:57:35 -0400 Subject: [PATCH 3/4] logger --- index.js | 13 ++++++++++--- lib/logger.js | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 2e044b8..f21ce85 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const _ = require('lodash'); const chalk = require('chalk') +const logs = require('./data/logs') var logger = require('./lib/logger') var arr = [1,2,3]; @@ -9,7 +10,13 @@ console.log(chalk.blue(number)); }) console.log(chalk.blue("Hello world!")); +_.each(logs, function(msg){ + logger.log(msg.message, msg.level ); -logger.log("testing", "INFO") -logger.log("testing", "WARNING") -logger.log("testing", "ERROR") + + +}) + +logger.log("testing", "info") +logger.log("testing", "warning") +logger.log("testing", "error") diff --git a/lib/logger.js b/lib/logger.js index 532cf9c..689a5cb 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,11 +1,11 @@ chalk = require('chalk') var logger = { log: function(message,level) { -if (level === "INFO") { +if (level === "info") { this.info(message) } - else if (level === "WARNING") { + else if (level === "warning") { this.warning(message) - } else if (level ==="ERROR") { + } else if (level ==="error") { this.error(message) }; }, From e3761bcd66a4ff3b7b181681347167d124d651c7 Mon Sep 17 00:00:00 2001 From: Elias Hantula Date: Tue, 31 Oct 2017 13:59:14 -0400 Subject: [PATCH 4/4] helloNode --- lib/logger.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 689a5cb..4694623 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -10,15 +10,15 @@ if (level === "info") { }; }, info: function(message) { - console.log(chalk.blue(message + " INFO level")); + console.log(chalk.blue(message)); }, warning: function(message){ - console.log(chalk.yellow(message + " WARNING level")); + console.log(chalk.yellow(message)); }, error: function(message) { - console.log(chalk.red(message + " ERROR level")); + console.log(chalk.red(message)); } };