From 506b0a82b91eb18556796316de0592a95f23196a Mon Sep 17 00:00:00 2001 From: Kenny Kottenstette Date: Sat, 25 Aug 2018 00:56:30 -0700 Subject: [PATCH 1/4] git test --- .gitignore | 1 + package.json | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .gitignore create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/package.json b/package.json new file mode 100644 index 0000000..f0054a8 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "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/kotten1/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/kotten1/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/kotten1/assignment_node_hello_world#readme" +} From 5a88d8bb8dbb9ac64de79badac92dc79b5ae97b3 Mon Sep 17 00:00:00 2001 From: Kenny Kottenstette Date: Sat, 25 Aug 2018 01:02:47 -0700 Subject: [PATCH 2/4] warmup complete --- index.js | 10 ++++++++++ package.json | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..8ef6a00 --- /dev/null +++ b/index.js @@ -0,0 +1,10 @@ +var _ = require("lodash"); +var chalk = require("chalk"); + +console.log(chalk.blue("yay")); + +var names = ["bob", "fred", "will"]; + +_.each(names, function(name){ + console.log(chalk.blue(name)) +}) diff --git a/package.json b/package.json index f0054a8..756e3f1 100644 --- a/package.json +++ b/package.json @@ -15,5 +15,9 @@ "bugs": { "url": "https://github.com/kotten1/assignment_node_hello_world/issues" }, - "homepage": "https://github.com/kotten1/assignment_node_hello_world#readme" + "homepage": "https://github.com/kotten1/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.4.1", + "lodash": "^4.17.10" + } } From f75fd7c16718eb456484a49312afe2dc196738b8 Mon Sep 17 00:00:00 2001 From: Kenny Kottenstette Date: Sat, 25 Aug 2018 01:23:37 -0700 Subject: [PATCH 3/4] begin testing --- index.js | 16 ++++++++++++++++ lib/logger.js | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 lib/logger.js diff --git a/index.js b/index.js index 8ef6a00..227d457 100644 --- a/index.js +++ b/index.js @@ -8,3 +8,19 @@ var names = ["bob", "fred", "will"]; _.each(names, function(name){ console.log(chalk.blue(name)) }) + +console.log() +console.log() +console.log() +console.log() + +//warmup end + +var logger = require("./lib/logger"); +logger.log('info level', 'info') +logger.log('warning level', 'warning') +logger.log('error level', 'error') +console.log(); +logger.info("info"); +logger.warning("warning"); +logger.error("error"); diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..268a273 --- /dev/null +++ b/lib/logger.js @@ -0,0 +1,24 @@ +var logger = module.exports; +var chalk = require('chalk'); + +logger.info = function(message){ + console.log( chalk.blue(message) ); +}; + + +logger.warning = function(message){ + console.log( chalk.yellow(message) ); +}; + + +logger.error = function(message){ + console.log( chalk.red(message) ); +}; + +logger.log = function(message, level){ + + if (level === "info") { this.info(message) }; + if (level === "warning") { this.warning(message) }; + if (level === "error") { this.error(message) }; + +}; From 2b83f4eefe022d1f6fd3a73b3f474d03a56b674f Mon Sep 17 00:00:00 2001 From: Kenny Kottenstette Date: Sat, 25 Aug 2018 02:02:06 -0700 Subject: [PATCH 4/4] excercise complete --- index.js | 7 +++++++ lib/logger.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/index.js b/index.js index 227d457..b4a61f3 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ var _ = require("lodash"); var chalk = require("chalk"); +var jsonLogs = require("./data/logs"); console.log(chalk.blue("yay")); @@ -24,3 +25,9 @@ console.log(); logger.info("info"); logger.warning("warning"); logger.error("error"); + +console.log("~~~~~"); + +_.each(jsonLogs, function(jsonLog){ + logger.log(jsonLog.message, jsonLog.level); +}) diff --git a/lib/logger.js b/lib/logger.js index 268a273..607b729 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,6 +1,8 @@ var logger = module.exports; var chalk = require('chalk'); + + logger.info = function(message){ console.log( chalk.blue(message) ); };