Created
May 3, 2018 13:33
-
-
Save ghale/0e67ca7edd1ddc07b445d88f85128a0b to your computer and use it in GitHub Desktop.
Standard error capturing init script
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
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