Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@



node_modules/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ assignment_node_hello_world
Just Node.js saying hello to the world and such.



Steven Zarrella

23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const _ = require('./node_modules/lodash');
const chalk = require('./node_modules/chalk');
const log = require('./lib/logger');

const JSONdata = require('./data/logs.json');

let testArray = [1, 2, 3, 4, 5];

console.log(chalk.blue("Hello world!"));

_.each(testArray, function(value) {
console.log(value * 2);
});


log("Hello world!", "info");
log("Hello world!", "WArning");
log("Hello world!", "ERROR");

//logging from JSON file
_.each(JSONdata, function(data) {
log(data.message, data.level);
});
22 changes: 22 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const chalk = require('../node_modules/chalk');

const log = function(message, level) {
let lowerLevel = level.toLowerCase();

switch(lowerLevel) {
case "info":
console.log(chalk.blue(message));
break;
case "warning":
console.log(chalk.yellow(message));
break;
case "error":
console.log(chalk.red(message));
break;
default:
console.log("LOGGER ERROR - Invalid log level");
break;
}
}

module.exports = log;
62 changes: 62 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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/stevenvz/assignment_node_hello_world.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/stevenvz/assignment_node_hello_world/issues"
},
"homepage": "https://github.com/stevenvz/assignment_node_hello_world#readme",
"dependencies": {
"chalk": "^2.1.0",
"lodash": "^4.17.4"
}
}