Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Created June 17, 2011 09:23
Show Gist options
  • Save kiy0taka/1031115 to your computer and use it in GitHub Desktop.
Save kiy0taka/1031115 to your computer and use it in GitHub Desktop.
@Grapes([@Grab('org.apache.ant:ant-javamail:1.8.1'), @GrabConfig(systemClassLoader=true)])
import groovy.ui.Console
import groovy.ui.SystemOutputInterceptor;
import javax.swing.UIManager
UIManager.lookAndFeel = UIManager.systemLookAndFeelClassName
def console = new Console()
def origin = console.&finishException
console.metaClass.finishException = { Throwable t, boolean executing ->
origin.call(t, executing)
Thread.start {
def interceptor = new SystemOutputInterceptor({str -> false})
interceptor.start()
def w = new StringWriter()
t.printStackTrace(new PrintWriter(w))
new AntBuilder().mail(mailhost:'smtp.gmail.com', mailport:'587',
subject:t.message, charset:'utf-8',
user:'[email protected]', password:'xxx', enableStartTLS:'on') {
from address:‘[email protected]
to address:'[email protected]'
message w.toString()
}
interceptor.stop()
}
}
console.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment