forked from I2P_Developers/i2p.i2p
Console: Get log level translations from core
This commit is contained in:
@ -9,6 +9,7 @@ import java.util.TreeSet;
|
|||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.router.web.HelperBase;
|
import net.i2p.router.web.HelperBase;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
import net.i2p.util.Translate;
|
||||||
|
|
||||||
public class ConfigLoggingHelper extends HelperBase {
|
public class ConfigLoggingHelper extends HelperBase {
|
||||||
public ConfigLoggingHelper() {}
|
public ConfigLoggingHelper() {}
|
||||||
@ -67,7 +68,8 @@ public class ConfigLoggingHelper extends HelperBase {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] levels = { _x("CRIT"), _x("ERROR"), _x("WARN"), _x("INFO"), _x("DEBUG") };
|
/** these are translated in the core bundle */
|
||||||
|
private static final String[] levels = { "CRIT", "ERROR", "WARN", "INFO", "DEBUG" };
|
||||||
|
|
||||||
public String getDefaultLogLevelBox() {
|
public String getDefaultLogLevelBox() {
|
||||||
String cur = _context.logManager().getDefaultLimit();
|
String cur = _context.logManager().getDefaultLimit();
|
||||||
@ -83,7 +85,7 @@ public class ConfigLoggingHelper extends HelperBase {
|
|||||||
buf.append("<option value=\"").append(l).append('\"');
|
buf.append("<option value=\"").append(l).append('\"');
|
||||||
if (l.equals(cur))
|
if (l.equals(cur))
|
||||||
buf.append(SELECTED);
|
buf.append(SELECTED);
|
||||||
buf.append('>').append(_t(l)).append("</option>\n");
|
buf.append('>').append(_c(l)).append("</option>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showRemove)
|
if (showRemove)
|
||||||
@ -136,4 +138,14 @@ public class ConfigLoggingHelper extends HelperBase {
|
|||||||
buf.append(getLogLevelBox("newloglevel", "WARN", false));
|
buf.append(getLogLevelBox("newloglevel", "WARN", false));
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String CORE_BUNDLE_NAME = "net.i2p.util.messages";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* translate a string from the core bundle
|
||||||
|
* @since 0.9.45
|
||||||
|
*/
|
||||||
|
private String _c(String s) {
|
||||||
|
return Translate.getString(s, _context, CORE_BUNDLE_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import net.i2p.router.web.ConfigServiceHandler;
|
|||||||
import net.i2p.router.web.HelperBase;
|
import net.i2p.router.web.HelperBase;
|
||||||
import net.i2p.router.web.RouterConsoleRunner;
|
import net.i2p.router.web.RouterConsoleRunner;
|
||||||
import net.i2p.util.FileUtil;
|
import net.i2p.util.FileUtil;
|
||||||
|
import net.i2p.util.Translate;
|
||||||
|
|
||||||
public class LogsHelper extends HelperBase {
|
public class LogsHelper extends HelperBase {
|
||||||
|
|
||||||
@ -150,14 +151,14 @@ public class LogsHelper extends HelperBase {
|
|||||||
// Homeland Security Advisory System
|
// Homeland Security Advisory System
|
||||||
// http://www.dhs.gov/xinfoshare/programs/Copy_of_press_release_0046.shtm
|
// http://www.dhs.gov/xinfoshare/programs/Copy_of_press_release_0046.shtm
|
||||||
// but pink instead of yellow for WARN
|
// but pink instead of yellow for WARN
|
||||||
if (msg.contains(_t("CRIT")))
|
if (msg.contains(_c("CRIT")))
|
||||||
color = "#cc0000";
|
color = "#cc0000";
|
||||||
else if (msg.contains(_t("ERROR")))
|
else if (msg.contains(_c("ERROR")))
|
||||||
color = "#ff3300";
|
color = "#ff3300";
|
||||||
else if (msg.contains(_t("WARN")))
|
else if (msg.contains(_c("WARN")))
|
||||||
// color = "#ff00cc"; poor legibility on light backgrounds
|
// color = "#ff00cc"; poor legibility on light backgrounds
|
||||||
color = "#bf00df";
|
color = "#bf00df";
|
||||||
else if (msg.contains(_t("INFO")))
|
else if (msg.contains(_c("INFO")))
|
||||||
color = "#000099";
|
color = "#000099";
|
||||||
else
|
else
|
||||||
color = "#006600";
|
color = "#006600";
|
||||||
@ -213,4 +214,14 @@ public class LogsHelper extends HelperBase {
|
|||||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String CORE_BUNDLE_NAME = "net.i2p.util.messages";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* translate a string from the core bundle
|
||||||
|
* @since 0.9.45
|
||||||
|
*/
|
||||||
|
private String _c(String s) {
|
||||||
|
return Translate.getString(s, _context, CORE_BUNDLE_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user