Skip to content

Commit

Permalink
fix: task redefine context logger (#1213)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Aug 9, 2021
1 parent a035ccb commit f8887c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages-serverless/serverless-vercel-starter/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "serverless-vercel-starter",
"name": "@midwayjs/serverless-vercel-starter",
"version": "2.12.1",
"main": "dist/index",
"typings": "dist/index.d.ts",
Expand Down
12 changes: 12 additions & 0 deletions packages/web/app/extend/context.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const rc = Symbol('Context#RequestContext');
const ctxLogger = Symbol('Context#ContextLogger');
const { MidwayRequestContainer } = require('@midwayjs/core');

module.exports = {
Expand All @@ -13,4 +14,15 @@ module.exports = {
get startTime() {
return this['starttime'];
},

get logger() {
if (this[ctxLogger]) {
return this[ctxLogger];
}
return this.getLogger('logger');
},

set logger(customLogger) {
this[ctxLogger] = customLogger;
},
};

0 comments on commit f8887c9

Please sign in to comment.