Skip to content

Commit

Permalink
fix: createLogger & commond-core support multi provider (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
echosoar committed Aug 18, 2020
1 parent 3e874a2 commit c1748f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/faas-cli-command-core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export class CommandHookCore implements ICommandHooksCore {
if (instance.provider) {
if (typeof instance.provider === 'string') {
pluginProvider = instance.provider;
} else if (Array.isArray(instance.provider)) {
// provider is list
if (instance.provider.indexOf(provider) === -1) {
return;
}
} else {
pluginProvider = instance.provider.constructor.getProviderName();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1595516163422
1597737411780
2 changes: 1 addition & 1 deletion packages/faas-cli-command-core/test/plugins/test.lg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BasePlugin } from '../../src';

class LogPlugin extends BasePlugin {
provider = 'test';
provider = ['test'];
commands = {
log: {
usage: 'log command',
Expand Down
10 changes: 8 additions & 2 deletions packages/runtime-engine/src/lib/loggerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ export class BaseLoggerFactory implements LoggerFactory {
this.Logger = Logger || ServerlessLogger;
}

createLogger(options?) {
options = options || {};
createLogger(options?);
createLogger(filename?, options?) {
if (typeof filename === 'string') {
options = options || {};
options.file = filename;
} else {
options = filename || {};
}
const lv = this.envParser ? this.envParser.getLoggerLevel() : 'ERROR';
if (lv) {
options.level = lv;
Expand Down

0 comments on commit c1748f0

Please sign in to comment.