Skip to content

Commit

Permalink
Merge pull request #13 from thinkjs/feat/context
Browse files Browse the repository at this point in the history
[FEAT] add context logger inject
  • Loading branch information
lizheming authored Jun 10, 2023
2 parents c69a2dd + 5f37502 commit 61580a8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const helper = require('think-helper');
const Logger = require('./');

const LOGGER = Symbol('logger');

module.exports = {
context: {
get logger() {
if (!this[LOGGER]) {
this[LOGGER] = new Logger(helper.parseAdapterConfig(this.config('logger')), true);
}

return this[LOGGER];
}
},
controller: {
get logger() {
return this.ctx.logger;
}
}
};

0 comments on commit 61580a8

Please sign in to comment.