Add RuntimeLogs() method for retrieving application runtime logs#124
Merged
Add RuntimeLogs() method for retrieving application runtime logs#124
Conversation
Provides a platform-agnostic API for retrieving runtime logs from deployed applications after staging completes. This complements the existing staging logs returned by platform.Deploy.Execute() by adding access to post-deployment application output. This change also refactors the log fetching logic introduced in commit 8fb0d65 by extracting a shared FetchRecentLogs() helper function, eliminating code duplication between staging failure logs and runtime logs retrieval. Key additions: - Add Deployment.RuntimeLogs() method for runtime log retrieval - Extract cloudfoundry.FetchRecentLogs() shared helper function - Add comprehensive tests for both CloudFoundry and Docker platforms - Update README with RuntimeLogs() usage examples Benefits: - Clear separation between staging logs (build-time) and runtime logs - Tests can verify application startup, service connections, module loading - Simplifies buildpack integration tests (no manual cf/docker logs commands) - Consolidates log fetching logic (DRY principle) - Self-documenting API with explicit method names Use cases: - Testing application startup messages - Verifying service connection logs (Redis, PostgreSQL, etc.) - Checking module/extension loading (PHP extensions, npm packages) - Validating runtime configuration - Debugging runtime errors Example usage: deployment, stagingLogs, err := platform.Deploy.Execute(name, path) Expect(err).NotTo(HaveOccurred()) // stagingLogs contains build-time output Expect(stagingLogs).To(ContainSubstring("Installing dependencies")) // RuntimeLogs() retrieves application output runtimeLogs, err := deployment.RuntimeLogs() Expect(err).NotTo(HaveOccurred()) Expect(runtimeLogs).To(ContainSubstring("Application started"))
robdimsdale
approved these changes
Dec 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a platform-agnostic
RuntimeLogs()API for retrieving logs from running applications after deployment succeeds. This complements the existing staging logs returned byplatform.Deploy.Execute()by providing access to post-deployment application output.This PR also refactors the log fetching logic introduced in #121 (commit 8fb0d65) by extracting a shared
FetchRecentLogs()helper function, eliminating code duplication between staging failure logs and runtime logs retrieval.Key Changes
Deployment.RuntimeLogs()method - Retrieves runtime logs for both CloudFoundry and Docker platformscloudfoundry.FetchRecentLogs()helper - Shared log fetching logic used by both staging failures and runtime logsAPI Design
The API provides clear separation between staging logs (build-time) and runtime logs:
Staging Logs (Build-Time)
platform.Deploy.Execute()Runtime Logs (Post-Deployment)
deployment.RuntimeLogs()methodUse Cases
This enhancement simplifies buildpack integration tests that need to verify runtime behavior:
Before (manual workaround):
After (simple API):
Example: Testing Both Staging and Runtime
Benefits
Improvements Over PR #121
This PR builds upon the staging failure logs work from #121 by:
cf logs --recentcode is now in a reusableFetchRecentLogs()helperstage.golog fetching reduced from 15 lines to 5 linesTesting
All tests pass:
FetchRecentLogs())Related