diff --git a/apps/routerconsole/java/bundle-messages.sh b/apps/routerconsole/java/bundle-messages.sh index 6ff85e4689caa892c84749725403f3f193b98520..19bcba45c5df856a81b0a1f6160b97285469949b 100755 --- a/apps/routerconsole/java/bundle-messages.sh +++ b/apps/routerconsole/java/bundle-messages.sh @@ -39,6 +39,7 @@ fi # router/ now has its own bundle for some files ROUTERFILES="\ ../../../router/java/src/net/i2p/router/Blocklist.java \ + ../../../router/java/src/net/i2p/router/Router.java \ ../../../router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java \ ../../../router/java/src/net/i2p/router/sybil/Analysis.java \ ../../../router/java/src/net/i2p/router/tasks/CoalesceStatsEvent.java \ diff --git a/core/java/src/net/i2p/util/LogWriter.java b/core/java/src/net/i2p/util/LogWriter.java index 9d7275e1e4b77e1fbc95ea2be3d04239b323daf7..450c51a34591696e52e1d1902a4816d5e485defd 100644 --- a/core/java/src/net/i2p/util/LogWriter.java +++ b/core/java/src/net/i2p/util/LogWriter.java @@ -166,6 +166,7 @@ abstract class LogWriter implements Runnable { } private static final String BUNDLE_NAME = "net.i2p.util.messages"; + private static final String ROUTER_BUNDLE_NAME = "net.i2p.router.web.messages"; /** * gettext @@ -222,7 +223,10 @@ abstract class LogWriter implements Runnable { if (name == null) name = "I2P"; } - ns.notify(name, null, priority, name, msg, null); + // the class name usually won't be translated, + // but it will be for "Router" + String tname = Translate.getString(name, _manager.getContext(), ROUTER_BUNDLE_NAME); + ns.notify(name, null, priority, tname, msg, null); } } } diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 1576e44feb90144ad86f52ad54b50f3489961767..83acdeb06d6f28b6e0c169e99ec596a33390e849 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -108,6 +108,7 @@ public class Router implements RouterClock.ClockShiftListener { private UPnPScannerCallback _upnpScannerCallback; private long _downtime = -1; + private static final String BUNDLE_NAME = "net.i2p.router.web.messages"; public final static String PROP_CONFIG_FILE = "router.configLocation"; /** let clocks be off by 1 minute */ @@ -1443,7 +1444,10 @@ public class Router implements RouterClock.ClockShiftListener { // help us shut down esp. after OOM int priority = (exitCode == EXIT_OOM) ? Thread.MAX_PRIORITY - 1 : Thread.NORM_PRIORITY + 2; Thread.currentThread().setPriority(priority); - _log.log(Log.CRIT, "Starting final shutdown(" + exitCode + ')'); + if (exitCode == EXIT_HARD_RESTART || exitCode == EXIT_GRACEFUL_RESTART) + _log.log(Log.CRIT, _t("Restart imminent")); + else + _log.log(Log.CRIT, _t("Shutdown imminent")); // So we can get all the way to the end // No, you can't do Thread.currentThread.setDaemon(false) if (_killVMOnEnd) { @@ -1943,7 +1947,7 @@ public class Router implements RouterClock.ClockShiftListener { f.delete(); if (lastWritten > 0) _eventLog.addEvent(EventLog.CRASHED, - Translate.getString("{0} ago", DataHelper.formatDuration2(downtime), _context, "net.i2p.router.web.messages")); + Translate.getString("{0} ago", DataHelper.formatDuration2(downtime), _context, BUNDLE_NAME)); } else { return false; } @@ -2137,4 +2141,12 @@ public class Router implements RouterClock.ClockShiftListener { recv = (int)rs.getRate(5*60*1000).getAverageValue(); return Math.max(send, recv); } + + /** + * Translate with console bundle + * @since 0.9.53 + */ + private final String _t(String s) { + return Translate.getString(s, _context, BUNDLE_NAME); + } } diff --git a/router/java/src/net/i2p/router/tasks/GracefulShutdown.java b/router/java/src/net/i2p/router/tasks/GracefulShutdown.java index 5d86a291b05b0c854eb18f673b9553392c25f758..ba2c4d49f1e7eb6d10d9504b7a1934dadde950eb 100644 --- a/router/java/src/net/i2p/router/tasks/GracefulShutdown.java +++ b/router/java/src/net/i2p/router/tasks/GracefulShutdown.java @@ -26,12 +26,14 @@ public class GracefulShutdown implements Runnable { int gracefulExitCode = _context.router().scheduledGracefulExitCode(); if (gracefulExitCode == Router.EXIT_HARD || gracefulExitCode == Router.EXIT_HARD_RESTART || _context.tunnelManager().getParticipatingCount() <= 0) { - if (gracefulExitCode == Router.EXIT_HARD) - log.log(Log.CRIT, "Shutting down after a brief delay"); - else if (gracefulExitCode == Router.EXIT_HARD_RESTART) - log.log(Log.CRIT, "Restarting after a brief delay"); - else - log.log(Log.CRIT, "Graceful shutdown progress: No more tunnels, starting final shutdown"); + if (log.shouldWarn()) { + if (gracefulExitCode == Router.EXIT_HARD) + log.warn("Shutting down after a brief delay"); + else if (gracefulExitCode == Router.EXIT_HARD_RESTART) + log.warn("Restarting after a brief delay"); + else + log.warn("Graceful shutdown progress: No more tunnels, starting final shutdown"); + } // Allow time for a UI reponse try { synchronized (Thread.currentThread()) {