diff --git a/packages/faas/src/framework.ts b/packages/faas/src/framework.ts index 6022205e082b..995fc059a3b9 100644 --- a/packages/faas/src/framework.ts +++ b/packages/faas/src/framework.ts @@ -99,6 +99,7 @@ export class MidwayFaaSFramework extends BaseFramework< this.appLogger = this.logger; loggers.addLogger('coreLogger', this.logger, false); loggers.addLogger('appLogger', this.logger, false); + loggers.addLogger('logger', this.logger, false); } } diff --git a/packages/faas/test/fixtures/base-app-inject-logger/src/index.ts b/packages/faas/test/fixtures/base-app-inject-logger/src/index.ts index 31cd6c42de08..3b2d520d212c 100644 --- a/packages/faas/test/fixtures/base-app-inject-logger/src/index.ts +++ b/packages/faas/test/fixtures/base-app-inject-logger/src/index.ts @@ -1,5 +1,5 @@ import { FunctionHandler } from '../../../../src'; -import { Func, Provide, App, Inject } from '@midwayjs/decorator'; +import { Func, Provide, App, Inject, Logger } from '@midwayjs/decorator'; import * as assert from 'assert'; @Provide() @@ -17,11 +17,23 @@ export class HelloService implements FunctionHandler { @Inject() ctx; + @Logger('logger') + anotherLogger; + + @Logger('appLogger') + anotherAppLogger; + + @Logger() + appLogger; + async handler() { assert(this.loggerService.getLogger()); assert(this.loggerService.getLogger() === this.app.getLogger()); assert(this.logger); assert(this.logger === this.ctx.logger); + assert(this.logger === this.appLogger); + assert(this.logger === this.anotherLogger); + assert(this.logger === this.anotherAppLogger); return 'hello world'; } }