From b741a6171c89e8049035f60df163a7cf498dea1d Mon Sep 17 00:00:00 2001 From: GeneTinderholm Date: Wed, 8 Nov 2017 04:00:17 -0600 Subject: [PATCH 1/2] initial commit --- .gitignore | 1 + .index.js.swp | Bin 0 -> 12288 bytes index.js | 9 +++++++ package-lock.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 23 +++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 .gitignore create mode 100644 .index.js.swp create mode 100644 index.js create mode 100644 package-lock.json 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.swp b/.index.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..5bf84ff31660c7e45e57dcd704950951a477e49e GIT binary patch literal 12288 zcmeI&yH3L}6b4|oTZOm?Rt7f=1PRgtOC^NF2m@>|fKcQnP7~_d;3VZHVC5Cy9e4_O z1vUmAg_EctE%fw#gDPpW6wJdHA zJJKw-yBmwjt*|?qOm#4!+Muoc zY6q8SAOHafKmY;|fB*y_009U<00IygLje&o_BO@X{4@=o{{Mfj|KI8Qnc|V+fg+%2 zQ*2Riin4wT=Zhgj00Izz00bZa0SG_<0uX=z1bztAYW!wtgVh3~Q=_D(Ovepkp}L-x zq1zWKmrIoQJt>0N71oN&17VkWl)a&&!SSb*C6YQJ8U`y0-ExPpotol?g=}FMcJ< LfqyS3Zxs0tC$Dq> literal 0 HcmV?d00001 diff --git a/index.js b/index.js new file mode 100644 index 0000000..c08bd38 --- /dev/null +++ b/index.js @@ -0,0 +1,9 @@ +const chalk = require('chalk'); +const _ = require('lodash'); +console.log(chalk.blue("Hello world!")); + +let arrayVar = ["hum", "dinger", "squeezy", "frolf"]; + +_.each(arrayVar, function(value){ + console.log(chalk.red(value)); +}); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ce7f113 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,62 @@ +{ + "name": "node_hello_world_project", + "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.0" + } + }, + "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.0", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "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..0b88681 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "node_hello_world_project", + "version": "1.0.0", + "description": "JS/Node Unit 1 Assignment 1", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/GeneTinderholm/assignment_node_hello_world.git" + }, + "author": "Gene Tinderholm", + "license": "ISC", + "bugs": { + "url": "https://github.com/GeneTinderholm/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/GeneTinderholm/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.3.0", + "lodash": "^4.17.4" + } +} From 05735f57b2fc19e7f41ef2d2bf44c681f73b5012 Mon Sep 17 00:00:00 2001 From: GeneTinderholm Date: Wed, 8 Nov 2017 05:01:09 -0600 Subject: [PATCH 2/2] logger works --- index.js | 9 ++++---- .index.js.swp => lib/.logger.js.swp | Bin 12288 -> 12288 bytes lib/logger.js | 32 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) rename .index.js.swp => lib/.logger.js.swp (92%) create mode 100644 lib/logger.js diff --git a/index.js b/index.js index c08bd38..4899d75 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,8 @@ const chalk = require('chalk'); const _ = require('lodash'); -console.log(chalk.blue("Hello world!")); +let myPack = require('./lib/logger.js'); +let neededJson = require('./data/logs.json'); -let arrayVar = ["hum", "dinger", "squeezy", "frolf"]; - -_.each(arrayVar, function(value){ - console.log(chalk.red(value)); +_.each(neededJson, function(item){ + myPack.log(item.message, item.level); }); diff --git a/.index.js.swp b/lib/.logger.js.swp similarity index 92% rename from .index.js.swp rename to lib/.logger.js.swp index 5bf84ff31660c7e45e57dcd704950951a477e49e..f35b981c6d605f846076e095c66af546ade7d627 100644 GIT binary patch literal 12288 zcmeI2KX21O7{)JA5i(K>q7&N@hB}gQ+@MHRD<&oey3v6pa-54};`qXy-5~K#f}tM+ zi7&vw7hq(AZvbisBt8X?jWe`L8`KT-So!JXyL;c<^RqI=gW%xdBe~-T0@n>8zMM3l zd{{eZ9M6P^Ri?`6RhP{RGhMX_>#xg(ox^03WN|07Hi@&T%JP1uhpInTX{!5kZPH;U zO$MD*$FVa0Q~MW(sKDxWJF79==tDpLv)@`|Y^YO(sT%`dTpaB}70UDqI z8lV9h_^%A)vxazsM9n&ttjETgvA*R%12jMbG(ZD1Km#;D12jMbG(ZD1@DCaYheGVH z3-Jq-|NqN6!;kAidgD98Yb0kR=49&?rKV_d) zGc*#5iV`cs5{q;c(n|A^OEUBGph~J47;;ie6kzfSwhGZo8Kt>OItofDnR)4{MIcsj zVQFe=RV9d-R+OKUrW9-K4s;oY%}GE@HIzJ3b8_+(%JYkIQWTXyZU8APQHTecU6fi_ Xnpu>pp`MeUl31Lfu4z5_zP=&=P;*}g diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..b59956b --- /dev/null +++ b/lib/logger.js @@ -0,0 +1,32 @@ +const chalk = require('chalk'); + +let logger = { + + info : function (message){ + console.log(chalk.rgb(0,0,255)(message)); + }, + + warning : function (message){ + console.log(chalk.rgb(255,255,0)(message)); + }, + + error : function (message){ + console.log(chalk.rgb(255,0,0)(message)); + }, + + log : function (message, level){ + switch(level){ + case "info": + this.info(message); + break; + case "warning": + this.warning(message); + break; + case "error": + this.error(message); + break; + } + } +} + +module.exports = logger;