Feb 162010
Thanks to the awesome groovy-ness of groovy this is crazy easy!
Controller action:
def appLog = { def file = new File("pathToApplicationLog.log") // Success. [log: file.text] } |
appLog.gsp:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="layout" content="main" /> <title>Application Log</title> </head> <body onload="textAreaScrollBottom('log');"> <h1>Application Log</h1> <div class="body"> <textarea rows="30" cols="90" id="log" name="log" readonly="yes"> ${log.encodeAsHTML()} </textarea> </div> <!--End body--> </body> </html> |
CSS:
#log { width: 920px; height: auto; } |
JavaScript:
function textAreaScrollBottom(id) { $(id).scrollTop = $(id).scrollHeight; } |
Render a log or text file with Grails…
Thanks to the awesome groovy-ness of groovy this is crazy easy!
Controller action:
def appLog = {
def file = new File(“pathToApplicationLog.log”)
// Success.
[log: file.text]
}…