From 5adeedae23b6fecb3ad0c5f2d4f3262fc67367b7 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Mon, 23 Oct 2017 19:42:09 -0500 Subject: [PATCH 1/3] initialcommit, warmup up done --- .gitignore | 1 + index.js | 15 +++++++++++++++ package.json | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..7b2a50b --- /dev/null +++ b/index.js @@ -0,0 +1,15 @@ +var _ = require('lodash'); +const chalk = require('chalk'); + + +console.log(chalk.green( + 'I am a green line ' + + chalk.blue.underline.bold('with a blue substring') + + ' that becomes green again!' +)); + +const array = [1,2,3]; + +_.each (array, function(n) { + console.log(`${n} potato`); +}) diff --git a/package.json b/package.json new file mode 100644 index 0000000..a54b3ae --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "assignment_node_hello_world", + "version": "1.0.0", + "description": "assignment_node_hello_world ===========================", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/memyselfandhai/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/memyselfandhai/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/memyselfandhai/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.2.0", + "lodash": "^4.17.4" + } +} From c79afc4d8b4c2cfa0754854b1b5f701e12262647 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Mon, 23 Oct 2017 20:19:24 -0500 Subject: [PATCH 2/3] logged completed --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7b2a50b..f8d5146 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,20 @@ var _ = require('lodash'); const chalk = require('chalk'); +var logger = require('./lib/logger') - +//chalk works console.log(chalk.green( 'I am a green line ' + chalk.blue.underline.bold('with a blue substring') + ' that becomes green again!' )); +//lodash works const array = [1,2,3]; _.each (array, function(n) { console.log(`${n} potato`); }) + + +logger.log('Messaged logged at ERROR level','ERROR'); From 3c92cb5f2873d9e6711c90750a9ad6ccf65e674a Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Tue, 24 Oct 2017 12:12:47 -0500 Subject: [PATCH 3/3] logger completed --- index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f8d5146..00796c2 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ var _ = require('lodash'); const chalk = require('chalk'); -var logger = require('./lib/logger') +var logger = require('./lib/logger'); +var messages = require('./data/logs.json'); //chalk works console.log(chalk.green( @@ -17,4 +18,12 @@ _.each (array, function(n) { }) -logger.log('Messaged logged at ERROR level','ERROR'); +// testing the logger +logger.log('Messaged logged at ERROR level','error'); + + +// logging from JSON +_.each (messages, function(value) { + logger.log(value.message, value.level); + +});