Refactor: Reduce duplicate logging patterns in launcher helpers#941
Closed
Refactor: Reduce duplicate logging patterns in launcher helpers#941
Conversation
…g duplication - Add tripleLogInfo() helper function that encapsulates the pattern of logging to three destinations (file, stdout, debug) at INFO level - Refactor logLaunchStart() and logLaunchSuccess() to use the new helper, reducing code duplication from the triple-logging pattern - Extract sessionSfx variable in logTimeoutError() for consistency - Fix pre-existing test failures: tests were expecting debug logger output (logLauncher.Printf) which only appears with DEBUG env var, but test harness only captures standard log output - Update test assertions to check for content that actually appears in captured output - Addresses duplicate code issues #930 and #931 (partial) Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
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.
Addresses duplicate code issues #930 and #931 from the February 2026 analysis. Three launcher logging functions (
logLaunchStart,logTimeoutError,logLaunchSuccess) contained ~45 lines of duplicated if/else branching and repetitive triple-logging calls (file, stdout, debug).Changes
Extracted
tripleLogInfo()helper: Encapsulates the pattern of logging to three destinations at INFO level, eliminating ~20 lines of duplicate code across session-aware logging functionsRefactored session-aware branching: Updated
logLaunchStart()andlogLaunchSuccess()to use the helper; extractedsessionSfxvariable inlogTimeoutError()for consistencyFixed pre-existing test failures: Tests expected debug logger output (
logLauncher.Printf) which only appears withDEBUGenv var set, but test harness only captures standard log output. Updated assertions to check actual captured content.Example
Before:
After:
Assessment of Issue #932
Global logger initialization wrappers (issue #932) already use generic helpers (
initGlobalLogger,closeGlobalLogger) that abstract complex logic. The type-specific wrappers provide stable, type-safe API and are acceptable as-is.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build2432024851/b279/launcher.test /tmp/go-build2432024851/b279/launcher.test -test.testlogfile=/tmp/go-build2432024851/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -l .; exit 1) x_amd64/compile /usr/bin/dirname-lang=go1.25 g_.a gKxUsK41W /home/REDACTED/.ca/tmp/go-build2110249177/b094/vet.cfg dirname /hom�� ache/Python/3.12-c=4 git ache/go/1.25.7/x-importcfg 64/src/runtime/c/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet L9DlBEyy1 x_amd64/compile base64(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build2432024851/b264/config.test /tmp/go-build2432024851/b264/config.test -test.testlogfile=/tmp/go-build2432024851/b264/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 86_64/git 64/pkg/tool/linu/tmp/go-build1419250802/b107/vet.cfg /opt/hostedtoolcache/Python/3.12.12/x64/bin/git go gS_UDtWia /opt/hostedtoolc/tmp/go-build2110249177/b054/vet.cfg git rev-�� --abbrev-ref HEAD ndor/bin/git 64/src/runtime/c/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet p6T44YG/Vlapd5iY/tmp/go-build2110249177/b205/vet.cfg .12/x64/bin/as base64(dns block)nonexistent.local/tmp/go-build2432024851/b279/launcher.test /tmp/go-build2432024851/b279/launcher.test -test.testlogfile=/tmp/go-build2432024851/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -l .; exit 1) x_amd64/compile /usr/bin/dirname-lang=go1.25 g_.a gKxUsK41W /home/REDACTED/.ca/tmp/go-build2110249177/b094/vet.cfg dirname /hom�� ache/Python/3.12-c=4 git ache/go/1.25.7/x-importcfg 64/src/runtime/c/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet L9DlBEyy1 x_amd64/compile base64(dns block)slow.example.com/tmp/go-build2432024851/b279/launcher.test /tmp/go-build2432024851/b279/launcher.test -test.testlogfile=/tmp/go-build2432024851/b279/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -l .; exit 1) x_amd64/compile /usr/bin/dirname-lang=go1.25 g_.a gKxUsK41W /home/REDACTED/.ca/tmp/go-build2110249177/b094/vet.cfg dirname /hom�� ache/Python/3.12-c=4 git ache/go/1.25.7/x-importcfg 64/src/runtime/c/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet L9DlBEyy1 x_amd64/compile base64(dns block)this-host-does-not-exist-12345.com/tmp/go-build2432024851/b288/mcp.test /tmp/go-build2432024851/b288/mcp.test -test.testlogfile=/tmp/go-build2432024851/b288/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true nner/.nvm git cal/bin/git _DIR) == 1 { /opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet R9l7N8J2z /usr/local/sbin//tmp/go-build2110249177/b163/vet.cfg head -n 1 git ache/Python/3.12.12/x64/git 64/src/runtime/c/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet 64/src/encoding//tmp/go-build2110249177/b249/vet.cfg ache/go/1.25.7/x64/pkg/tool/linu-lang=go1.25 base64(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt