translate log priorities

This commit is contained in:
zzz
2010-05-15 15:42:20 +00:00
parent 2c26b8d422
commit ace57a96a9
4 changed files with 37 additions and 3 deletions

View File

@ -625,4 +625,12 @@ public class LogManager {
shutdown();
}
}
/**
* Convenience method for LogRecordFormatter
* @since 0.7.14
*/
I2PAppContext getContext() {
return _context;
}
}

View File

@ -14,6 +14,8 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import net.i2p.I2PAppContext;
/**
* Render a log record according to the log manager's settings
*
@ -44,7 +46,7 @@ class LogRecordFormatter {
buf.append(getThread(rec));
break;
case LogManager.PRIORITY:
buf.append(getPriority(rec));
buf.append(getPriority(rec, manager.getContext()));
break;
case LogManager.MESSAGE:
buf.append(getWhat(rec));
@ -78,10 +80,23 @@ class LogRecordFormatter {
return manager.getDateFormat().format(new Date(logRecord.getDate()));
}
/** don't translate */
private static String getPriority(LogRecord rec) {
return toString(Log.toLevelString(rec.getPriority()), MAX_PRIORITY_LENGTH);
}
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";
/** translate @since 0.7.14 */
private static String getPriority(LogRecord rec, I2PAppContext ctx) {
int len;
if (Translate.getLanguage(ctx).equals("de"))
len = 8; // KRITISCH
else
len = MAX_PRIORITY_LENGTH;
return toString(Translate.getString(Log.toLevelString(rec.getPriority()), ctx, BUNDLE_NAME), len);
}
private static String getWhat(LogRecord rec) {
return rec.getMessage();
}
@ -92,6 +107,7 @@ class LogRecordFormatter {
return toString(src, MAX_WHERE_LENGTH);
}
/** truncates or pads to the specified size */
private static String toString(String str, int size) {
StringBuilder buf = new StringBuilder();
if (str == null) str = "";
@ -101,4 +117,4 @@ class LogRecordFormatter {
buf.append(' ');
return buf.toString();
}
}
}

View File

@ -1,3 +1,13 @@
2010-05-15 zzz
* Console:
- Tag text in graphs
- Move SummaryRenderer to its own file
* Eepsite: Set no-cache in redirecting page
* Hash: Move caching XOR methods only used by KBucket
into netdb
* i2psnark: CSS tweaks
* Log: Translate priority
2010-05-13 zzz
* netdb.jsp debug tweaks
* Plugins: Try to prevent ZipErrors after upgrade

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 6;
public final static long BUILD = 7;
/** for example "-test" */
public final static String EXTRA = "";