Skip to content

Instantly share code, notes, and snippets.

@ghale
Created May 3, 2018 13:33
Show Gist options
  • Save ghale/0e67ca7edd1ddc07b445d88f85128a0b to your computer and use it in GitHub Desktop.
Save ghale/0e67ca7edd1ddc07b445d88f85128a0b to your computer and use it in GitHub Desktop.
Standard error capturing init script
rootProject {
def errorFile = file("${rootProject.buildDir}/errors.log")
def errorListener = new ErrorCapture(errorFile)
allprojects {
logging.addStandardErrorListener(errorListener)
tasks.all {
logging.addStandardErrorListener(errorListener)
}
}
}
class ErrorCapture implements StandardOutputListener {
private final File errorFile
ErrorCapture(File errorFile) {
this.errorFile = errorFile
errorFile.parentFile.mkdirs()
}
void onOutput(CharSequence output) {
errorFile << output
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment