MCPcopy Index your code
hub / github.com/serverless/serverless / tailLogs

Method tailLogs

packages/util/src/docker/index.js:629–654  ·  view source on GitHub ↗

* 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 = () => {},
  })

Source from the content-addressed store, hash-verified

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

Callers 1

#restartLogTailingMethod · 0.80

Calls 1

getContainerIfExistsMethod · 0.95

Tested by

no test coverage detected