Skip to content

Commit b8cd946

Browse files
author
hongqi.gan
committed
feat: remove time cost comment
1 parent 0720d93 commit b8cd946

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

lib/commands/server.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,15 @@ exports.run = function (options) {
8989
// logger
9090
app.use(function (req, res, next) {
9191
var end = res.end;
92-
req._startTime = new Date();
9392

9493
res.end = function (chunk, encoding) {
9594
// res.end = end;
96-
end.call(res, chunk, encoding, function () {
97-
log(req.url + ' cost ' + (Date.now() - req._startTime));
98-
});
95+
end.call(res, chunk, encoding);
9996

10097
var isNotMap = sysPath.extname(req.url) !== '.map';
10198
var isNotHotUpdate = req.url.indexOf('hot-update') === -1;
10299
if (isNotMap && isNotHotUpdate) {
103-
var format = '%date %status %method %url %contentLength %cost';
100+
var format = '%date %status %method %url %contentLength';
104101

105102
var parseResult = parse(req, res, format);
106103
return process.nextTick(function () {
@@ -138,7 +135,6 @@ exports.run = function (options) {
138135
format = format.replace(/%url/g, decodeURI(req.originalUrl));
139136
format = format.replace(/%status/g, String(res.statusCode)[statusColor]);
140137
format = format.replace(/%contentLength/g, contentLength.grey);
141-
format = format.replace(/%cost/g, Date.now() - req._startTime);
142138

143139
return {
144140
message: format,

src/commands/server.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,15 @@ exports.run = (options) => {
7171
// logger
7272
app.use((req, res, next) => {
7373
const end = res.end;
74-
req._startTime = new Date;
7574

7675
res.end = (chunk, encoding) => {
7776
// res.end = end;
78-
end.call(res, chunk, encoding, function() {
79-
log(`${req.url} cost ${Date.now() - req._startTime}`);
80-
});
77+
end.call(res, chunk, encoding);
8178

8279
const isNotMap = sysPath.extname(req.url) !== '.map';
8380
const isNotHotUpdate = req.url.indexOf('hot-update') === -1;
8481
if(isNotMap && isNotHotUpdate) {
85-
let format = '%date %status %method %url %contentLength %cost';
82+
let format = '%date %status %method %url %contentLength';
8683

8784
const parseResult = parse(req, res, format);
8885
return process.nextTick(() => {
@@ -122,7 +119,6 @@ exports.run = (options) => {
122119
format = format.replace(/%url/g, decodeURI(req.originalUrl));
123120
format = format.replace(/%status/g, String(res.statusCode)[statusColor]);
124121
format = format.replace(/%contentLength/g, contentLength.grey);
125-
format = format.replace(/%cost/g, Date.now() - req._startTime);
126122

127123
return {
128124
message: format,

0 commit comments

Comments
 (0)