Skip to content

Commit

Permalink
Fixes #42 - Completely replace the AWS logs hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Schmid committed May 26, 2017
1 parent 0403a14 commit 011cec4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,22 @@ class AwsAlias {

// Override the logs command - must be, because the $LATEST filter
// in the original logs command is not easy to change without hacks.
'before:logs:logs': () => BbPromise.bind(this)
'logs:logs': () => BbPromise.bind(this)
.then(this.validate)
.then(this.logsValidate)
.then(this.logsGetLogStreams)
.then(this.logsShowLogs)
.then(() => process.exit(0)), // Bail out to prevent the roiginal logs to be started!
.then(this.logsShowLogs),

'alias:remove:remove': () => BbPromise.bind(this)
.then(this.validate)
.then(this.aliasStackLoadCurrentCFStackAndDependencies)
.spread(this.removeAlias)
};

// Patch hooks to override our event replacements
const pluginManager = this.serverless.pluginManager;
const logHooks = pluginManager.hooks['logs:logs'];
_.pullAllWith(logHooks, [ 'AwsLogs' ], (a, b) => a.pluginName === b);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ module.exports = {
logsShowLogs(logStreamNames) {
if (!logStreamNames || !logStreamNames.length) {
if (this.options.tail) {
return setTimeout((() => this.getLogStreams()
.then(nextLogStreamNames => this.showLogs(nextLogStreamNames))),
return setTimeout((() => this.logsGetLogStreams()
.then(nextLogStreamNames => this.logsShowLogs(nextLogStreamNames))),
this.options.interval);
}
}
Expand Down Expand Up @@ -137,8 +137,8 @@ module.exports = {
this.options.startTime = _.last(results.events).timestamp + 1;
}

return setTimeout((() => this.getLogStreams()
.then(nextLogStreamNames => this.showLogs(nextLogStreamNames))),
return setTimeout((() => this.logsGetLogStreams()
.then(nextLogStreamNames => this.logsShowLogs(nextLogStreamNames))),
this.options.interval);
}

Expand Down

0 comments on commit 011cec4

Please sign in to comment.