Skip to content

Instantly share code, notes, and snippets.

@mykola-dev
Created September 16, 2015 08:17
Show Gist options
  • Save mykola-dev/77983977b4127ec417f3 to your computer and use it in GitHub Desktop.
Save mykola-dev/77983977b4127ec417f3 to your computer and use it in GitHub Desktop.
gradle log with timestamps
gradle.useLogger(new TimestampEventLogger())
class TimestampEventLogger extends BuildAdapter implements TaskExecutionListener {
def timestamp = 0L
public void beforeExecute(Task task) {
print "> $task.project.name:$task.name "
timestamp = System.currentTimeMillis()
}
public void afterExecute(Task task, TaskState state) {
def elapsed=(System.currentTimeMillis()-timestamp)/1000F
println "[$elapsed]"
}
public void buildFinished(BuildResult result) {
println 'build completed'
if (result.failure != null) {
result.failure.printStackTrace()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment