2004-07-24 02:06:07 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
2004-07-31 23:19:23 +00:00
|
|
|
import java.util.Properties;
|
|
|
|
import java.util.TreeSet;
|
2004-07-24 02:06:07 +00:00
|
|
|
|
|
|
|
import net.i2p.router.RouterContext;
|
|
|
|
|
2009-01-29 02:16:18 +00:00
|
|
|
public class ConfigLoggingHelper extends HelperBase {
|
2004-07-24 02:06:07 +00:00
|
|
|
public ConfigLoggingHelper() {}
|
|
|
|
|
|
|
|
public String getLogFilePattern() {
|
|
|
|
return _context.logManager().getBaseLogfilename();
|
|
|
|
}
|
|
|
|
public String getRecordPattern() {
|
|
|
|
return new String(_context.logManager().getFormat());
|
|
|
|
}
|
|
|
|
public String getDatePattern() {
|
|
|
|
return _context.logManager().getDateFormatPattern();
|
|
|
|
}
|
|
|
|
public String getMaxFileSize() {
|
|
|
|
int bytes = _context.logManager().getFileSize();
|
|
|
|
if (bytes == 0) return "1m";
|
|
|
|
if (bytes > 1024*1024*1024)
|
|
|
|
return (bytes/(1024*1024*1024)) + "g";
|
|
|
|
else if (bytes > 1024*1024)
|
|
|
|
return (bytes/(1024*1024)) + "m";
|
|
|
|
else
|
|
|
|
return (bytes/(1024)) + "k";
|
|
|
|
}
|
|
|
|
public String getLogLevelTable() {
|
2009-07-01 16:00:43 +00:00
|
|
|
StringBuilder buf = new StringBuilder(32*1024);
|
2004-07-31 23:19:23 +00:00
|
|
|
Properties limits = _context.logManager().getLimits();
|
|
|
|
TreeSet sortedLogs = new TreeSet();
|
|
|
|
for (Iterator iter = limits.keySet().iterator(); iter.hasNext(); ) {
|
|
|
|
String prefix = (String)iter.next();
|
|
|
|
sortedLogs.add(prefix);
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
2004-07-31 23:19:23 +00:00
|
|
|
|
2008-09-15 16:23:47 +00:00
|
|
|
buf.append("<textarea name=\"levels\" rows=\"20\" cols=\"90\">");
|
2004-07-31 23:19:23 +00:00
|
|
|
for (Iterator iter = sortedLogs.iterator(); iter.hasNext(); ) {
|
|
|
|
String prefix = (String)iter.next();
|
|
|
|
String level = limits.getProperty(prefix);
|
|
|
|
buf.append(prefix).append('=').append(level).append('\n');
|
2004-07-24 02:06:07 +00:00
|
|
|
}
|
|
|
|
buf.append("</textarea><br />\n");
|
2005-12-09 08:05:44 +00:00
|
|
|
buf.append("<i>Add additional logging statements above. Example: net.i2p.router.tunnel=WARN</i><br>");
|
|
|
|
buf.append("<i>Or put entries in the logger.config file. Example: logger.record.net.i2p.router.tunnel=WARN</i><br>");
|
2004-07-24 02:06:07 +00:00
|
|
|
buf.append("<i>Valid levels are DEBUG, INFO, WARN, ERROR, CRIT</i>\n");
|
|
|
|
return buf.toString();
|
|
|
|
}
|
2004-07-31 23:19:23 +00:00
|
|
|
public String getDefaultLogLevelBox() {
|
|
|
|
String cur = _context.logManager().getDefaultLimit();
|
2009-07-01 16:00:43 +00:00
|
|
|
StringBuilder buf = new StringBuilder(128);
|
2004-07-31 23:19:23 +00:00
|
|
|
buf.append("<select name=\"defaultloglevel\">\n");
|
|
|
|
|
|
|
|
buf.append("<option value=\"DEBUG\" ");
|
2004-08-01 23:21:35 +00:00
|
|
|
if ("DEBUG".equals(cur)) buf.append(" selected=\"true\" ");
|
2004-07-31 23:19:23 +00:00
|
|
|
buf.append(">DEBUG</option>\n");
|
|
|
|
|
|
|
|
buf.append("<option value=\"INFO\" ");
|
|
|
|
if ("INFO".equals(cur)) buf.append(" selected=\"true\" ");
|
|
|
|
buf.append(">INFO</option>\n");
|
|
|
|
|
|
|
|
buf.append("<option value=\"WARN\" ");
|
|
|
|
if ("WARN".equals(cur)) buf.append(" selected=\"true\" ");
|
|
|
|
buf.append(">WARN</option>\n");
|
|
|
|
|
|
|
|
buf.append("<option value=\"ERROR\" ");
|
2004-08-01 23:21:35 +00:00
|
|
|
if ("ERROR".equals(cur)) buf.append(" selected=\"true\" ");
|
2004-07-31 23:19:23 +00:00
|
|
|
buf.append(">ERROR</option>\n");
|
|
|
|
|
|
|
|
buf.append("<option value=\"CRIT\" ");
|
|
|
|
if ("CRIT".equals(cur)) buf.append(" selected=\"true\" ");
|
|
|
|
buf.append(">CRIT</option>\n");
|
|
|
|
|
|
|
|
buf.append("</select>\n");
|
2004-07-24 02:06:07 +00:00
|
|
|
return buf.toString();
|
|
|
|
}
|
|
|
|
}
|