* Tails logs for a container * @param {Object} params * @param {string} params.containerName - Name of the container to tail logs for * @param {Function} [params.onData] - Callback function to handle log data * @returns {Promise }
({
containerName,
onData = () => {},
onError = () => {},
onEnd = () => {},
})
| 627 | * @returns {Promise<void>} |
| 628 | */ |
| 629 | async tailLogs({ |
| 630 | containerName, |
| 631 | onData = () => {}, |
| 632 | onError = () => {}, |
| 633 | onEnd = () => {}, |
| 634 | }) { |
| 635 | const serviceContainer = await this.getContainerIfExists({ containerName }) |
| 636 | |
| 637 | if (!serviceContainer) { |
| 638 | throw new ServerlessError( |
| 639 | `Unable to tail logs due to container "${containerName}" not found`, |
| 640 | 'CONTAINER_NOT_FOUND', |
| 641 | ) |
| 642 | } |
| 643 | const stream = await serviceContainer.logs({ |
| 644 | follow: true, |
| 645 | stdout: true, |
| 646 | stderr: true, |
| 647 | }) |
| 648 | |
| 649 | stream.on('data', onData) |
| 650 | stream.on('error', onError) |
| 651 | stream.on('end', onEnd) |
| 652 | |
| 653 | return stream |
| 654 | } |
| 655 | |
| 656 | /** |
| 657 | * Pushes a Docker image |
no test coverage detected