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/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/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" +}