Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

morgan

Package Overview
Dependencies
Maintainers
6
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morgan - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

12

History.md

@@ -0,1 +1,13 @@

1.1.0 / 2014-05-18
==================
* "dev" format will use same tokens as other formats
* `:response-time` token is now empty when immediate used
* `:response-time` token is now monotonic
* `:response-time` token has precision to 1 μs
* fix `:status` + immediate output in node.js 0.8
* improve `buffer` option to prevent indefinite event loop holding
* deps: bytes@1.0.0
- add negative support
1.0.1 / 2014-05-04

@@ -2,0 +14,0 @@ ==================

60

index.js

@@ -31,8 +31,6 @@ /*!

exports = module.exports = function logger(options) {
if ('object' == typeof options) {
options = options || {};
} else if (options) {
if (options && typeof options !== 'object') {
options = { format: options };
} else {
options = {};
options = options || {};
}

@@ -59,9 +57,12 @@

var realStream = stream
, buf = []
, interval = 'number' == typeof buffer
? buffer
: defaultBufferDuration;
var buf = []
var timer = null
var interval = 'number' == typeof buffer
? buffer
: defaultBufferDuration
// flush interval
setInterval(function(){
// flush function
var flush = function(){
timer = null
if (buf.length) {

@@ -71,3 +72,3 @@ realStream.write(buf.join(''));

}
}, interval);
}

@@ -77,2 +78,6 @@ // swap the stream

write: function(str){
if (timer === null) {
timer = setTimeout(flush, interval)
}
buf.push(str);

@@ -85,2 +90,3 @@ }

var sock = req.socket;
req._startAt = process.hrtime();
req._startTime = new Date;

@@ -180,21 +186,12 @@ req._remoteAddress = sock.socket ? sock.socket.remoteAddress : sock.remoteAddress;

exports.format('dev', function(tokens, req, res){
var status = res.statusCode
, len = parseInt(res.getHeader('Content-Length'), 10)
, color = 32;
var color = 32; // green
var status = res.statusCode;
if (status >= 500) color = 31
else if (status >= 400) color = 33
else if (status >= 300) color = 36;
if (status >= 500) color = 31; // red
else if (status >= 400) color = 33; // yellow
else if (status >= 300) color = 36; // cyan
len = isNaN(len)
? ''
: len = ' - ' + bytes(len);
var fn = compile('\x1b[90m:method :url \x1b[' + color + 'm:status \x1b[90m:response-time ms - :res[content-length]\x1b[0m');
return '\x1b[90m' + req.method
+ ' ' + (req.originalUrl || req.url) + ' '
+ '\x1b[' + color + 'm' + res.statusCode
+ ' \x1b[90m'
+ (new Date - req._startTime)
+ 'ms' + len
+ '\x1b[0m';
return fn(tokens, req, res);
});

@@ -222,4 +219,7 @@

exports.token('response-time', function(req){
return String(Date.now() - req._startTime);
exports.token('response-time', function(req, res){
if (!res._header || !req._startAt) return '';
var diff = process.hrtime(req._startAt);
var ms = diff[0] * 1e3 + diff[1] * 1e-6;
return ms.toFixed(3);
});

@@ -240,3 +240,3 @@

exports.token('status', function(req, res){
return res.headersSent ? res.statusCode : null;
return res._header ? res.statusCode : null;
});

@@ -243,0 +243,0 @@

{
"name": "morgan",
"description": "connect's logger for node.js",
"version": "1.0.1",
"description": "http request logger middleware for node.js",
"version": "1.1.0",
"author": {

@@ -11,2 +11,8 @@ "name": "Jonathan Ong",

},
"contributors": [
{
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
}
],
"license": "MIT",

@@ -22,6 +28,8 @@ "repository": {

"dependencies": {
"bytes": "0.3.0"
"bytes": "1.0.0"
},
"devDependencies": {
"mocha": "~1.18.2",
"coveralls": "2.10.0",
"istanbul": "0.2.10",
"mocha": "~1.19.0",
"should": "~3.3.1",

@@ -34,4 +42,6 @@ "supertest": "~0.12.0"

"scripts": {
"test": "mocha --require should --reporter spec --bail"
"test": "mocha --require should --reporter dot",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require should --reporter dot",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require should --reporter spec && (cat ./coverage/lcov.info | coveralls || true)"
}
}

@@ -1,2 +0,2 @@

# morgan [![Build Status](https://travis-ci.org/expressjs/morgan.svg)](https://travis-ci.org/expressjs/morgan) [![NPM version](https://badge.fury.io/js/morgan.svg)](http://badge.fury.io/js/morgan)
# morgan [![NPM version](https://badge.fury.io/js/morgan.svg)](http://badge.fury.io/js/morgan) [![Build Status](https://travis-ci.org/expressjs/morgan.svg)](https://travis-ci.org/expressjs/morgan) [![Coverage Status](https://img.shields.io/coveralls/expressjs/morgan.svg)](https://coveralls.io/r/expressjs/morgan)

@@ -3,0 +3,0 @@ Logging middleware for node.js http apps.

Sorry, the diff of this file is not supported yet

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