-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support better logger timer in precise milliseconds
detail see eggjs/egg-logger#74 How to use: ```js // config.js exports.logger = { enablePerformanceTimer: true, }; ```
- Loading branch information
Showing
13 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/fixtures/apps/app-enablePerformanceTimer-true/app/controller/home.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = async (ctx) => { | ||
ctx.body = 'hello performanceStarttime: ' + ctx.performanceStarttime; | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/apps/app-enablePerformanceTimer-true/app/router.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = app => { | ||
app.get('home', '/', 'home'); | ||
}; |
8 changes: 8 additions & 0 deletions
8
test/fixtures/apps/app-enablePerformanceTimer-true/config/config.default.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
exports.logger = { | ||
level: 'DEBUG', | ||
enablePerformanceTimer: true, | ||
}; | ||
|
||
exports.keys = 'foo'; |
5 changes: 5 additions & 0 deletions
5
test/fixtures/apps/app-enablePerformanceTimer-true/config/config.unittest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
exports.logger = { | ||
consoleLevel: 'NONE', | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/apps/app-enablePerformanceTimer-true/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "app-enablePerformanceTimer-true" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const utils = require('../../utils'); | ||
|
||
describe('test/lib/core/context_performance_starttime.test.js', () => { | ||
let app; | ||
|
||
before(() => { | ||
app = utils.app('apps/app-enablePerformanceTimer-true'); | ||
return app.ready(); | ||
}); | ||
|
||
it('should set ctx.performanceStarttime', () => { | ||
const ctx = app.mockContext(); | ||
assert(ctx.performanceStarttime); | ||
assert(ctx.performanceStarttime > 0); | ||
assert(typeof ctx.performanceStarttime === 'number'); | ||
}); | ||
|
||
it('should use ctx.performanceStarttime on controller', async () => { | ||
const res = await app.httpRequest() | ||
.get('/'); | ||
assert(res.status === 200); | ||
assert(/hello performanceStarttime: \d+\.\d+/.test(res.text)); | ||
}); | ||
}); |