-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeLogs.groovy
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.avast.gradle.dockercompose.tasks | ||
|
||
import com.avast.gradle.dockercompose.ComposeSettings | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
class ComposeLogs extends DefaultTask { | ||
|
||
ComposeSettings settings | ||
|
||
ComposeLogs() { | ||
group = 'docker' | ||
description = 'Records log output from services in containers of docker-compose project' | ||
} | ||
|
||
@TaskAction | ||
void logs() { | ||
|
||
if( !settings.containerLogToDir ) { | ||
println 'Not recording container logs: containerLogToDir not specified.' | ||
return | ||
} | ||
|
||
settings.composeExecutor.serviceNames.each { service -> | ||
println "Extracting container log from service '${service}'" | ||
new File(settings.containerLogToDir).mkdirs() | ||
def logStream = new FileOutputStream("${settings.containerLogToDir}/${service}.log") | ||
String[] args = ['logs', '-t', service] | ||
settings.composeExecutor.executeWithCustomOutputWithExitValue(logStream, args) | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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