Skip to content

Commit

Permalink
Rename responselog middleware to requestlog.
Browse files Browse the repository at this point in the history
  • Loading branch information
hns committed May 27, 2011
1 parent 08a3ea1 commit 6df3599
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
7 changes: 4 additions & 3 deletions examples/demo.js
Expand Up @@ -42,11 +42,12 @@ prod.configure("gzip", "etag", "error");
prod.error.location = false; // disable error location and stack traces

// development environment, run with RINGO_ENV=development ringo demo.js
var dev = app.env("development").configure("responselog", "error");
dev.responselog.append = true;
var dev = app.env("development").configure("requestlog", "error");
dev.requestlog.append = true;

// profiler environment, run with RINGO_ENV=profiler ringo -o-1 demo.js
app.env("profiler").configure("responselog", "profiler", "error");
var prof = app.env("profiler").configure("requestlog", "profiler", "error");
prof.requestlog.append = true;

// create a password protected admin application
var admin = new Application(dummyPage("admin zone"));
Expand Down
4 changes: 2 additions & 2 deletions lib/stick/middleware.js
Expand Up @@ -36,8 +36,8 @@ exports.profiler = require("./middleware/profiler");
/** Middleware for [template based response rendering](./render/index.html). */
exports.render = require("./middleware/render");

/** Middleware for [appending log messages to the HTTP response](./responselog/index.html). */
exports.responselog = require("./middleware/responselog");
/** Middleware for [collecting log messages per HTTP request](./requestlog/index.html). */
exports.requestlog = require("./middleware/requestlog");

/** Middleware for [intra-app request routing](./route/index.html). */
exports.route = require("./middleware/route");
Expand Down
Expand Up @@ -2,16 +2,16 @@
* @fileOverview Middleware for collecting log messages issued during execution
* of the current request.
*
* This adds a `responselog` property to the application object with an `items`
* This adds a `requestlog` property to the application object with an `items`
* property. During execution of a request `items` contains an array containing
* all the log messages issued for the request. Log messages are represented
* as arrays in the format `[time, level, name, message]`.
*
* During request execution, the `responselog` property also defines a
* During request execution, the `requestlog` property also defines a
* property called `start` containing the time the execution started.
*
* By default, messages are appended to the response if its Content-Type is
* `text/html`. This can be controlled using the `app.responselog.append`
* `text/html`. This can be controlled using the `app.requestlog.append`
* boolean flag.
*/

Expand Down Expand Up @@ -41,12 +41,12 @@ logging.on("info", collect.bind(undefined, "info"));
logging.on("warn", collect.bind(undefined, "warn"));
logging.on("error", collect.bind(undefined, "error"));

function ResponseLog() {
function RequestLog() {
this.enable = true;
this.append = true;
}

Object.defineProperties(ResponseLog.prototype, {
Object.defineProperties(RequestLog.prototype, {
items: {
get: function() {
var obj = threadMap.get(Thread.currentThread());
Expand All @@ -71,13 +71,13 @@ Object.defineProperties(ResponseLog.prototype, {
* @param {Object} app the Stick Application object
* @returns {Function} a JSGI middleware function
*/
exports.middleware = function responselog(next, app) {
exports.middleware = function requestlog(next, app) {

app.responselog = new ResponseLog();
app.requestlog = new RequestLog();

return function responselog(request) {
return function requestlog(request) {

if (!app.responselog.enable) {
if (!app.requestlog.enable) {
return next(request);
}

Expand All @@ -99,7 +99,7 @@ exports.middleware = function responselog(next, app) {
if (!contained) threadMap.remove(thread);
}

if (app.responselog.append) {
if (app.requestlog.append) {
var {status, headers, body} = response;

// only do this for ordinary HTML responses
Expand Down

0 comments on commit 6df3599

Please sign in to comment.