Skip to content

Commit

Permalink
Moved call to set the page on the response logger from (#659)
Browse files Browse the repository at this point in the history
renderMiddleware(onNavigate) to Navigator.handlePage. This will include
all logs leading up to and during the execution the handleRoute method.
  • Loading branch information
vinsewah authored and gigabo committed Sep 16, 2016
1 parent 0d3b0ba commit 052e332
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/react-server/core/context/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var EventEmitter = require('events').EventEmitter,
Q = require('q'),
History = require("../components/History"),
ReactServerAgent = require("../ReactServerAgent"),
PageUtil = require("../util/PageUtil");
PageUtil = require("../util/PageUtil"),
{setResponseLoggerPage} = SERVER_SIDE ? require('../logging/response') : { setResponseLoggerPage: () => {} };

var _ = {
isFunction: require('lodash/isFunction'),
Expand Down Expand Up @@ -184,6 +185,10 @@ class Navigator extends EventEmitter {
isRawResponse : false,
});

// Set the page context on the response logger so it can figure
// out whether to flush logs to the response document
setResponseLoggerPage(page);

// call page.handleRoute(), and use the resulting code to decide how to
// respond.
// We call it in a promise handler so any exception that
Expand Down
5 changes: 1 addition & 4 deletions packages/react-server/core/renderMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var logger = require('./logging').getLogger(__LOGGER__),
StringEscapeUtil = require('./util/StringEscapeUtil'),
{getRootElementAttributes} = require('./components/RootElement'),
{PAGE_CSS_NODE_ID, PAGE_LINK_NODE_ID, PAGE_CONTENT_NODE_ID, PAGE_CONTAINER_NODE_ID} = require('./constants'),
{setResponseLoggerPage, flushLogsToResponse} = require('./logging/response');
{flushLogsToResponse} = require('./logging/response');

var _ = {
map: require('lodash/map'),
Expand Down Expand Up @@ -132,9 +132,6 @@ module.exports = function(server, routes) {
return;
}
}
// Set the page context on the response logger so it can figure
// out whether to flush logs to the response document
setResponseLoggerPage(page);
renderPage(req, res, context, start, page);

});
Expand Down

0 comments on commit 052e332

Please sign in to comment.