(serverless, options, pluginUtils)
| 12 | |
| 13 | class AwsLogs { |
| 14 | constructor(serverless, options, pluginUtils) { |
| 15 | this.serverless = serverless |
| 16 | this.options = options || {} |
| 17 | this.provider = this.serverless.getProvider('aws') |
| 18 | this.logger = pluginUtils.log |
| 19 | this.progress = pluginUtils.progress |
| 20 | |
| 21 | Object.assign(this, validate) |
| 22 | |
| 23 | this.hooks = { |
| 24 | 'logs:logs': async () => { |
| 25 | if (!this.options.function && !this.options.agent) { |
| 26 | throw new ServerlessError( |
| 27 | 'One of the required options must be provided: --function (-f) or --agent (-a)', |
| 28 | 'LOGS_MISSING_OPTION', |
| 29 | ) |
| 30 | } |
| 31 | |
| 32 | if (this.options.agent) { |
| 33 | return |
| 34 | } |
| 35 | |
| 36 | if (!this.options.tail) { |
| 37 | this.progress.notice('Fetching logs') |
| 38 | } else { |
| 39 | this.logger.aside( |
| 40 | `Streaming new logs for function: "${this.options.function}"`, |
| 41 | ) |
| 42 | this.progress.notice('Listening') |
| 43 | } |
| 44 | this.extendedValidate() |
| 45 | const logStreamNames = await this.getLogStreams() |
| 46 | await this.showLogs(logStreamNames) |
| 47 | }, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | extendedValidate() { |
| 52 | this.validate() |
nothing calls this directly
no test coverage detected