From 0000eadd81fb5d60cc8933a2ca4c61dc53a6a1fe Mon Sep 17 00:00:00 2001 From: SarahSchoonmaker Date: Sun, 19 Nov 2017 22:48:05 -0500 Subject: [PATCH 1/2] initial --- .gitignore | 1 + assignment_node_hello_world | 1 + 2 files changed, 2 insertions(+) create mode 100644 .gitignore create mode 160000 assignment_node_hello_world diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/assignment_node_hello_world b/assignment_node_hello_world new file mode 160000 index 0000000..dafd504 --- /dev/null +++ b/assignment_node_hello_world @@ -0,0 +1 @@ +Subproject commit dafd5044c735ad9c428a0c138e4fd5ac88dfe7de From 8d70524d903bfe4ca47ab38d4673da9280c0acad Mon Sep 17 00:00:00 2001 From: SarahSchoonmaker Date: Sun, 19 Nov 2017 22:58:19 -0500 Subject: [PATCH 2/2] initial --- README.md | 5 +---- assignment_node_hello_world | 1 - data/logs.json | 0 index.js | 16 ++++++++++++++++ lib/logger.js | 24 ++++++++++++++++++++++++ lib/salutations.json | 9 +++++++++ package.json | 24 ++++++++++++++++++++++++ 7 files changed, 74 insertions(+), 5 deletions(-) mode change 100644 => 100755 README.md delete mode 160000 assignment_node_hello_world mode change 100644 => 100755 data/logs.json create mode 100755 index.js create mode 100755 lib/logger.js create mode 100755 lib/salutations.json create mode 100755 package.json diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 468464f..2e41e3e --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ -assignment_node_hello_world -=========================== +Node logger assignment -Just Node.js saying hello to the world and such. - diff --git a/assignment_node_hello_world b/assignment_node_hello_world deleted file mode 160000 index dafd504..0000000 --- a/assignment_node_hello_world +++ /dev/null @@ -1 +0,0 @@ -Subproject commit dafd5044c735ad9c428a0c138e4fd5ac88dfe7de diff --git a/data/logs.json b/data/logs.json old mode 100644 new mode 100755 diff --git a/index.js b/index.js new file mode 100755 index 0000000..a280760 --- /dev/null +++ b/index.js @@ -0,0 +1,16 @@ +var chalk = require("chalk"); +var _ = require("lodash"); +var logger = require("./lib/logger"); +var logs = require("./data/logs"); + +logger.log("This is a string", "INFO"); +logger.log("This is a warning", "WARNING"); +logger.log("This is an error", "ERROR"); + +logger.error("This is an error"); +logger.info("This is some info"); +logger.warning("this is a warning"); + +_.forEach(logs, function(key) { + logger.log(key.message, key.level.toUpperCase()); +}); \ No newline at end of file diff --git a/lib/logger.js b/lib/logger.js new file mode 100755 index 0000000..f25818e --- /dev/null +++ b/lib/logger.js @@ -0,0 +1,24 @@ +var chalk = require("chalk"); + +var logger = { + log: function(message, messageType) { + if (messageType === "ERROR") { + console.log(chalk.red(message)); + } else if (messageType === "WARNING") { + console.log(chalk.yellow(message)); + } else if (messageType === "INFO") { + console.log(chalk.blue(message)); + } + }, + info: function(message) { + console.log(chalk.blue(message)); + }, + warning: function(message) { + console.log(chalk.yellow(message)); + }, + error: function(message) { + console.log(chalk.red(message)); + } +}; + +module.exports = logger; \ No newline at end of file diff --git a/lib/salutations.json b/lib/salutations.json new file mode 100755 index 0000000..f6b0478 --- /dev/null +++ b/lib/salutations.json @@ -0,0 +1,9 @@ +{ + "en": "Hello world!", + "es": "Hola mundo!" +} + + + + + diff --git a/package.json b/package.json new file mode 100755 index 0000000..74fa294 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "demo_node_hello_world", + "version": "1.0.0", + "description": "demo_node_js_assignment", + "main": "index.js", + "dependencies": { + "chalk": "^2.3.0", + "lodash": "^4.17.4" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Sarah", + "license": "ISC", + "repository": { + "type": "git", + "url": "git+https://github.com/SarahSchoonmaker/assignment_node_hello_world.git" + }, + "bugs": { + "url": "https://github.com/SarahSchoonmaker/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/SarahSchoonmaker/assignment_node_hello_world#readme" +}