Skip to content

Commit 136fd60

Browse files
Add option to always print server logs (#163)
Spawned from #68
1 parent 91b0879 commit 136fd60

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

ONBOARDING.md

+6
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ There is no syntactically pleasing way to do this. Create a separate function wh
163163

164164
This is done using standard Go testing mechanisms, use `t.Logf(...)` which will be logged only if the test fails or if `-v` is set. Note that you will not need to log HTTP requests performed using one of the built in deployment clients as they are already wrapped in loggers. For full HTTP logs, use `COMPLEMENT_DEBUG=1`.
165165

166+
167+
### How do I show the server logs even when the tests pass?
168+
169+
Normally, server logs are only printed when one of the tests fail. To override that behavior to always show server logs, you can use `COMPLEMENT_ALWAYS_PRINT_SERVER_LOGS=1`.
170+
171+
166172
### How do I skip a test?
167173

168174
Use one of `t.Skipf(...)` or `t.SkipNow()`.

internal/config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Complement struct {
1010
BaseImageURI string
1111
BaseImageArgs []string
1212
DebugLoggingEnabled bool
13+
AlwaysPrintServerLogs bool
1314
BestEffort bool
1415
VersionCheckIterations int
1516
KeepBlueprints []string
@@ -20,6 +21,7 @@ func NewConfigFromEnvVars() *Complement {
2021
cfg.BaseImageURI = os.Getenv("COMPLEMENT_BASE_IMAGE")
2122
cfg.BaseImageArgs = strings.Split(os.Getenv("COMPLEMENT_BASE_IMAGE_ARGS"), " ")
2223
cfg.DebugLoggingEnabled = os.Getenv("COMPLEMENT_DEBUG") == "1"
24+
cfg.AlwaysPrintServerLogs = os.Getenv("COMPLEMENT_ALWAYS_PRINT_SERVER_LOGS") == "1"
2325
cfg.VersionCheckIterations = parseEnvWithDefault("COMPLEMENT_VERSION_CHECK_ITERATIONS", 100)
2426
cfg.KeepBlueprints = strings.Split(os.Getenv("COMPLEMENT_KEEP_BLUEPRINTS"), " ")
2527
if cfg.BaseImageURI == "" {

internal/docker/deployment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type HomeserverDeployment struct {
3131
// will print container logs before killing the container.
3232
func (d *Deployment) Destroy(t *testing.T) {
3333
t.Helper()
34-
d.Deployer.Destroy(d, t.Failed())
34+
d.Deployer.Destroy(d, d.Deployer.config.AlwaysPrintServerLogs || t.Failed())
3535
}
3636

3737
// Client returns a CSAPI client targeting the given hsName, using the access token for the given userID.

0 commit comments

Comments
 (0)