Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: createLogger & commond-core support multi provider #604

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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