Created
June 17, 2011 09:23
-
-
Save kiy0taka/1031115 to your computer and use it in GitHub Desktop.
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
@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