diff --git a/index.js b/index.js new file mode 100644 index 0000000..5fa79c9 --- /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()); +}); diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..bee98a8 --- /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; diff --git a/package.json b/package.json new file mode 100644 index 0000000..b092662 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "assignment_node_hello_world", + "version": "1.0.0", + "description": "assignment_node_hello_world\r ===========================", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jaredjgebel/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/jaredjgebel/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/jaredjgebel/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.1.0", + "lodash": "^4.17.4" + } +}