diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09ede39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + + +node_modules/ diff --git a/data/.logs.json.swp b/data/.logs.json.swp new file mode 100644 index 0000000..b818649 Binary files /dev/null and b/data/.logs.json.swp differ diff --git a/index.js b/index.js new file mode 100644 index 0000000..85780d7 --- /dev/null +++ b/index.js @@ -0,0 +1,22 @@ +let _ = require('lodash'); +let chalk = require('chalk'); +let Logger = require('./lib/logger'); +let json = require('./data/logs'); + +let logger = new Logger(); + +console.log(chalk.blue('Hello') + 'World' + chalk.red('!')); + +_.each([1,2,3], function(el, idx) { + console.log(el); +}); + +console.log("hello world"); + +logger.log("This should be blue", "INFO"); +logger.log("This should be yellow", "WARNING"); +logger.log("This should be red", "ERROR"); + +_.each(json, function(obj, idx) { + logger.log(obj.message, obj.level); +}); diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..70be4f1 --- /dev/null +++ b/lib/logger.js @@ -0,0 +1,27 @@ +let chalk = require('chalk'); + +class Logger { + constructor() {} + + info(message) { + return chalk.blue(message); + } + warning(message) { + return chalk.yellow(message); + } + error(message) { + return chalk.red(message); + } + log(message, level) { + switch(level.toLowerCase()) { + case "info": + return console.log(this.info(message)); + case "warning": + return console.log(this.warning(message)); + case "error": + return console.log(this.error(message)); + } + } +} + +module.exports = Logger; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..aa20a71 --- /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.1" + } + }, + "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.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "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..daddc36 --- /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/JohnRPB/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/JohnRPB/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/JohnRPB/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.3.0", + "lodash": "^4.17.4" + } +}