New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

demi-logger

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

demi-logger - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

178

lib/logger.js

@@ -39,97 +39,97 @@ /*

module.exports = function(tokens, req, res) {
//Date
var date = new Date();
//Logger
var protocol = req.protocol.toUpperCase().bold;
var ip = tokens['remote-addr'](req, res);
var method = req.method;
var mili = tokens['response-time'](req, res).cyan + 'ms'.cyan;
var routePath = tokens.url(req, res).green;
var status = String(tokens.status(req, res));
var by = req.xhr ? 'Ajax'.bold.green : 'No Ajax';
module.exports = function (tokens, req, res) {
//Date
var date = new Date();
//Logger
var protocol = req.protocol.toUpperCase().bold;
var ip = tokens['remote-addr'](req, res);
var method = req.method;
var mili = tokens['response-time'](req, res).cyan + 'ms'.cyan;
var routePath = tokens.url(req, res).green;
var status = String(tokens.status(req, res));
var by = req.xhr ? 'Ajax'.bold.green : 'No Ajax';
var showMethod = function() {
//storage
var result;
//Check
switch (req.method) {
case 'GET':
result = '[' + method.green + ']' + ' --> ' + ip.green;
break;
case 'POST':
result = '[' + method.yellow + ']' + ' --> ' + ip.yellow;
break;
case 'PUT':
result = '[' + method.cyan + ']' + ' --> ' + ip.cyan;
break;
case 'DELETE':
result = '[' + method.red + ']' + ' --> ' + ip.red;
break;
}
var showMethod = function () {
//storage
var result;
//Check
switch (req.method) {
case 'GET':
result = '[' + method.green + ']' + ' --> ' + ip.green;
break;
case 'POST':
result = '[' + method.yellow + ']' + ' --> ' + ip.yellow;
break;
case 'PUT':
result = '[' + method.cyan + ']' + ' --> ' + ip.cyan;
break;
case 'DELETE':
result = '[' + method.red + ']' + ' --> ' + ip.red;
break;
}
//return
return result;
};
//return
return result;
};
var showStatus = function() {
//storage
var result;
//Check
switch (status) {
case '200':
result = status.green + ' OK'.green;
break;
case '301':
result = status.cyan + ' Moved Permanently'.cyan;
break;
case '302':
result = status.cyan + ' Found'.cyan;
break;
case '304':
result = status.cyan + ' Not Modified'.cyan;
break;
case '400':
result = status.red + ' Bad Request'.red;
break;
case '401':
result = status.yellow + ' Unauthorized'.yellow;
break;
case '403':
result = status.yellow + ' Forbidden'.yellow;
break;
case '404':
result = status.yellow + ' Not Found'.yellow;
break;
case '500':
result = status.red + ' Internal Server Error'.red;
break;
case '503':
result = status.red + ' Service Unavailable'.red;
break;
default:
result = status.red;
break;
}
var showStatus = function () {
//storage
var result;
//Check
switch (status) {
case '200':
result = status.green + ' OK'.green;
break;
case '301':
result = status.cyan + ' Moved Permanently'.cyan;
break;
case '302':
result = status.cyan + ' Found'.cyan;
break;
case '304':
result = status.cyan + ' Not Modified'.cyan;
break;
case '400':
result = status.red + ' Bad Request'.red;
break;
case '401':
result = status.yellow + ' Unauthorized'.yellow;
break;
case '403':
result = status.yellow + ' Forbidden'.yellow;
break;
case '404':
result = status.yellow + ' Not Found'.yellow;
break;
case '500':
result = status.red + ' Internal Server Error'.red;
break;
case '503':
result = status.red + ' Service Unavailable'.red;
break;
default:
result = status.red;
break;
}
//return
return result;
};
//return
return result;
};
//Logger
console.log('[ ' + protocol + ' ]' + ' ' + showMethod() + ' --> ' + by + ' --> ' + mili + ' --> ' + showStatus() + ' ==> ' + routePath);
//Received data
if (req.body) {
console.log();
console.log('[ ' + 'Received'.green.bold + ' ] ==> ');
if (process.env.NODE_ENV === 'development') {
console.log(prettyjson.render({
body: req.body,
params: req.params,
query: req.query
}));
//Logger
console.log('[ ' + protocol + ' ]' + ' ' + showMethod() + ' --> ' + by + ' --> ' + mili + ' --> ' + showStatus() + ' ==> ' + routePath);
//Received data
if (req.body) {
console.log();
if (process.env.NODE_ENV === 'development') {
console.log('[ ' + 'Received'.green.bold + ' ] ==> ');
console.log(prettyjson.render({
body: req.body,
params: req.params,
query: req.query
}));
}
console.log();
}
console.log();
}
};
};
{
"name": "demi-logger",
"description": "Demi.js middleware for advanced logging",
"version": "0.1.3",
"homepage": "https://github.com/chrisenytc/demi-logger",
"author": {
"name": "Christopher EnyTC",
"email": "chrisenytc@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/chrisenytc/demi-logger.git"
},
"bugs": {
"url": "https://github.com/chrisenytc/demi-logger/issues"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/chrisenytc/demi-logger/blob/master/LICENSE"
}],
"main": "lib/logger",
"engines": {
"node": ">= 0.10.0"
},
"scripts": {
"test": "gulp test"
},
"dependencies": {
"colors": "~0.6.2",
"prettyjson": "~0.11.1"
},
"devDependencies": {
"mocha": "~1.10.0",
"chai": "~1.8.0",
"gulp": "~3.5.0",
"gulp-jshint": "~1.3.4",
"gulp-mocha": "~0.4.1",
"jshint-stylish": "~0.1.5"
},
"keywords": ["demiddleware", "advanced", "express", "log", "logging", "logger"]
}
"name": "demi-logger",
"description": "Demi.js middleware for advanced logging",
"version": "0.1.4",
"homepage": "https://github.com/chrisenytc/demi-logger",
"author": {
"name": "Christopher EnyTC",
"email": "chrisenytc@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/chrisenytc/demi-logger.git"
},
"bugs": {
"url": "https://github.com/chrisenytc/demi-logger/issues"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/chrisenytc/demi-logger/blob/master/LICENSE"
}],
"main": "lib/logger",
"engines": {
"node": ">= 0.10.0"
},
"scripts": {
"test": "gulp test"
},
"dependencies": {
"colors": "~0.6.2",
"prettyjson": "~0.11.1"
},
"devDependencies": {
"mocha": "~1.10.0",
"chai": "~1.8.0",
"gulp": "~3.5.0",
"gulp-jshint": "~1.3.4",
"gulp-mocha": "~0.4.1",
"jshint-stylish": "~0.1.5"
},
"keywords": ["demiddleware", "advanced", "express", "log", "logging", "logger"]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc