You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by je...@apache.org on 2003/01/28 11:29:04 UTC
cvs commit: xml-forrest/src/resources/forrestbot/webapp tail_refreshlog.jsp
jefft 2003/01/28 02:29:04
Modified: src/resources/forrestbot/webapp tail_refreshlog.jsp
Log:
Avoid errors when the log is <1000 bytes
Revision Changes Path
1.2 +8 -2 xml-forrest/src/resources/forrestbot/webapp/tail_refreshlog.jsp
Index: tail_refreshlog.jsp
===================================================================
RCS file: /home/cvs/xml-forrest/src/resources/forrestbot/webapp/tail_refreshlog.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tail_refreshlog.jsp 7 Dec 2002 09:33:59 -0000 1.1
+++ tail_refreshlog.jsp 28 Jan 2003 10:29:04 -0000 1.2
@@ -1,10 +1,16 @@
<%@page import="java.io.*" contentType="text/plain"%>
-<%! private static final String LOG_FILE="/WEB-INF/refresh_log.txt"; %>
+<%!
+private static final String LOG_FILE="/WEB-INF/refresh_log.txt";
+/** Number of bytes to print on each refresh */
+private static final int TAIL_SIZE=1000;
+%>
+
<%
File f = new File(getServletContext().getRealPath(LOG_FILE));
if (f.exists()) {
String logs = forrestbot.IOUtil.toString(new FileReader(f));
- out.println(logs.substring(logs.length()-1000));
+ int len = logs.length();
+ out.println( ((len < TAIL_SIZE) ? logs : logs.substring(logs.length()-TAIL_SIZE)) );
} else { %>
Log file <%=LOG_FILE%> not found.