Skip to content

refactor: remove internal/logger from platform run#378

Merged
mwbrooks merged 6 commits intomainfrom
mwbrooks-chopping-the-log-4
Mar 10, 2026
Merged

refactor: remove internal/logger from platform run#378
mwbrooks merged 6 commits intomainfrom
mwbrooks-chopping-the-log-4

Conversation

@mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented Mar 10, 2026

Changelog

  • N/A

Summary

This pull request is Part 4 of removing internal/logger package and is focused on the the run command.

Test Steps

# Create Deno SDK project
$ lack create my-app -t https://github.com/slack-samples/deno-starter-template
$ cd my-app/

# Run dev server
$ lack run
# → Confirm output formatting looks correct
# CTRL+C

# Restart dev server
$ lack run
# → Confirm output formatting looks correct

# Change file: Manifest
$ vim manifest.ts
# → Change the description and save
# → Confirm "Manifest change detected:"
# CTRL+C

# Clean up
$ lack delete -f
$ cd ..
$ rm -rf my-app/

Requirements

@mwbrooks mwbrooks added this to the Next Release milestone Mar 10, 2026
@mwbrooks mwbrooks self-assigned this Mar 10, 2026
@mwbrooks mwbrooks added code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment labels Mar 10, 2026
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 12.90323% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.43%. Comparing base (2ae86a3) to head (32a741d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/pkg/platform/run.go 0.00% 19 Missing ⚠️
internal/pkg/platform/localserver.go 36.36% 7 Missing ⚠️
cmd/platform/run.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #378      +/-   ##
==========================================
+ Coverage   65.27%   65.43%   +0.16%     
==========================================
  Files         216      216              
  Lines       17994    17937      -57     
==========================================
- Hits        11745    11737       -8     
+ Misses       5160     5112      -48     
+ Partials     1089     1088       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member Author

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments to connect the dots for the reviewers 🗺️ 📍

// OnEvent
func(event *logger.LogEvent) {
switch event.Name {
case "on_update_app_install":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This event was never used, disappointingly 😢

`Updating local app install for "%s"`,
event.DataToString("teamName"),
)))
case "on_cloud_run_connection_connected":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

case "on_cloud_run_connection_connected":
clients.IO.PrintTrace(ctx, slacktrace.PlatformRunReady)
cmd.Println(style.Secondary("Connected, awaiting events"))
case "on_cloud_run_connection_message":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

case "on_cloud_run_connection_message":
message := event.DataToString("cloud_run_connection_message")
clients.IO.PrintDebug(ctx, "received: %s", message)
case "on_cloud_run_connection_command_error":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

case "on_cloud_run_connection_command_error":
message := event.DataToString("cloud_run_connection_command_error")
clients.IO.PrintError(ctx, "Error: %s", message)
case "on_cloud_run_watch_error":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved to 3 places

cmd.Println(style.Secondary(fmt.Sprintf("Manifest change detected: %s, reinstalling app...", path)))
case "on_cloud_run_watch_manifest_change_reinstalled":
cmd.Println(style.Secondary("App successfully reinstalled"))
case "on_cloud_run_watch_manifest_change_skipped_remote":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

case "on_cloud_run_watch_manifest_change_skipped_remote":
path := event.DataToString("cloud_run_watch_manifest_change_skipped")
cmd.Println(style.Secondary(fmt.Sprintf("Manifest change detected: %s, skipped reinstalling app because manifest.source=remote", path)))
case "on_cloud_run_watch_app_change":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

case "on_cloud_run_watch_app_change":
path := event.DataToString("cloud_run_watch_app_change")
cmd.Println(style.Secondary(fmt.Sprintf("App change detected: %s, restarting server...", path)))
case "on_cleanup_app_install_done":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

`Cleaned up local app install for "%s".`,
event.DataToString("teamName"),
)))
case "on_cleanup_app_install_failed":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Moved here

)))
message := event.DataToString("on_cleanup_app_install_error")
clients.IO.PrintWarning(ctx, "Local app cleanup failed: %s", message)
case "on_abort_cleanup_app_install":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Never called

@mwbrooks mwbrooks changed the title refactor: remove logger from platform run refactor: remove internal/logger from platform run Mar 10, 2026
@mwbrooks mwbrooks marked this pull request as ready for review March 10, 2026 17:24
@mwbrooks mwbrooks requested a review from a team as a code owner March 10, 2026 17:24
Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks LGTM! Thanks for keeping these improvement chugging along 🌲 🚂 💨

Comment on lines -491 to +484
r.log.Data["cloud_run_watch_app_change"] = event.Path
r.log.Info("on_cloud_run_watch_app_change")
r.clients.IO.PrintInfo(ctx, false, "%s", style.Secondary(fmt.Sprintf("App change detected: %s, restarting server...", event.Path)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ praise: Inlining variables with outputs makes this more simple to reason about! We've talked about styling within pkg but I remain optimistic for this surfacing within perhaps cmd in the future!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on both points! Some of these outputs are complex and passing the variables through another layer has led to a number of issues - some of which we're just noticing as we flatten it!

internal/pkg is serving it's purpose well - as a shameful reminder that it must go away. I agree that moving more into cmd/ seems to be the right choice.

Comment on lines +207 to 216
func deleteAppOnTerminate(ctx context.Context, clients *shared.ClientFactory, auth types.SlackAuth, app types.App, teamName string) {
clients.IO.PrintDebug(ctx, "Removing the local version of this app from the workspace")
_, _, err := apps.Delete(ctx, clients, app.TeamDomain, app, auth)
if err != nil {
log.Data["on_cleanup_app_install_error"] = err.Error()
log.Info("on_cleanup_app_install_failed")
clients.IO.PrintInfo(ctx, false, "%s", style.Secondary(fmt.Sprintf(`Cleaning up local app install for "%s" failed.`, teamName)))
clients.IO.PrintWarning(ctx, "Local app cleanup failed: %s", err)
} else {
clients.IO.PrintInfo(ctx, false, "%s", style.Secondary(fmt.Sprintf(`Cleaned up local app install for "%s".`, teamName)))
}
log.Info("on_cleanup_app_install_done")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 thought(non-blocking): Using a familiar iostreams package for these outputs might make this inlined logic more simple to test also! Thanks so much for finding these changes 🎁

variables, err := clients.Config.GetDotEnvFileVariables()
if err != nil {
return nil, "", slackerror.Wrap(err, slackerror.ErrLocalAppRun).
return "", slackerror.Wrap(err, slackerror.ErrLocalAppRun).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎆 praise: Wrapping errors is a most exciting pattern we should continue to support!

break
}

r.log.Info("on_cloud_run_connection_command_output")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪬 note: I don't believe this log was output either!

🗣️ ramble: Inlining these outputs makes me so much more confident that we're outputting messages we expect more often. I saw in #367 that the run command now shows details on app installation progress. These are such appreciated changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw in #367 that the run command now shows details on app installation progress. These are such appreciated changes.

Heh, I just noticed that while testing this PR as well. I had to go back to our latest production release to double-check that I wasn't crazy 🤪

@mwbrooks
Copy link
Member Author

@zimeg Thanks for much for the review, again! 🙇🏻 Only one more PR left! 🤞🏻

@mwbrooks mwbrooks merged commit 1ab5496 into main Mar 10, 2026
8 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-chopping-the-log-4 branch March 10, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants