Skip to content

Commit

Permalink
fix: set error logger key (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Mar 30, 2021
1 parent cae14de commit 25b4302
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/faas/src/framework.ts
Expand Up @@ -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);
}
}

Expand Down
14 changes: 13 additions & 1 deletion 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()
Expand All @@ -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';
}
}

0 comments on commit 25b4302

Please sign in to comment.