Skip to content
Myr

Merge branch 'integration'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parents 6469046, dcedca1 · Browse files · 7 files+112 added−77 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+112 added−77 removed

  • tests:+0 added−24 removed
  • other:+112 added−53 removed

7 files+112 added−77 removed

modified:examples/chat/app.js+1 added-1 removed
modified:examples/upload/app.js+1 added-1 removed
deleted:lib/express/plugins/common-logger.js-50 removed
added:lib/express/plugins/logger.js+109 added
12// Express - Logger - Copyright Aaron Heckmann <aaronheckmann+express@gmail.com> (MIT Licensed)34/**5 * Module dependencies.6 */7 8var sys = require('sys')910/**11 * Log formats12 */13 14var formats = {15 common: function (event, start) {16 return [event.request.connection.remoteAddress, 17 '-', 18 '-',19 '[' + formatDate(new Date) + ']', 20 '"' + event.request.method.toUpperCase() + ' ' + (event.request.url.pathname || '/') + 21 ' HTTP/' + event.request.httpVersion + '"',22 event.request.response.status,23 event.request.response.headers['content-length'] || 0,24 ((Number(new Date) - start) / 1000).toFixed(3)25 ].join(' ')26 },27 combined: function (event) {28 return [formats.common(event),29 '"' + (event.request.headers['referrer'] || event.request.headers['referer'] || '-') + '"',30 '"' + (event.request.headers['user-agent'] || '') + '"'31 ].join(' ')32 },33 plot: function (event, start) {34 return Number(new Date) - start35 }36}373839/**40 * Months.41 */4243var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']4445/**46 * Format _date_.47 *48 * @param {Date} date49 * @return {string}50 * @api private51 */52 53function formatDate(date) {54 var d = date.getDate(),55 m = months[date.getMonth()],56 y = date.getFullYear(),57 h = date.getHours(),58 mi = date.getMinutes(),59 s = date.getSeconds()60 return (d < 10 ? '0' : '') + d + '/' + m + '/' + y + ' ' +61 (h < 10 ? '0' : '') + h + ':' + (mi < 10 ? '0' : '') + 62 mi + ':' + (s < 10 ? '0' : '') + s63}646566// --- Logger6768exports.Logger = Plugin.extend({ 69 extend: {70 71 /**72 * Initialize logger options.73 *74 * Options:75 *76 * - format77 * 'common' outputs log in CommonLog format (DEFAULT)78 * 'combined' outputs log in Apache Combined format79 * 'plot' outputs request duration in milliseconds only80 *81 * @param {hash} options82 * @api private83 */8485 init: function(options) {86 this.merge(options || {})87 }88 },89 90 on: {91 92 /**93 * Start timer.94 */95 96 request: function(event) {97 this.start = Number(new Date)98 },99 100 /**101 * Output log data.102 */103 104 response: function(event) {105 var format = formats[exports.Logger.format || 'common']106 sys.puts(format(event, this.start))107 }108 }109})
modified:lib/express/plugins.js+1 added-1 removed
modified:spec/node.js-1 removed
23 unmodified lines
24 'static',25 'plugins',26 'plugins.cache',27 'plugins.view',28 'plugins.common-logger',28 'plugins.content-length',29 'plugins.method-override',30 'plugins.body-decoder',31 'plugins.redirect',
17 unmodified lines
deleted:spec/spec.plugins.common-logger.js-23 removed