expose some data for the router console to query

This commit is contained in:
jrandom
2004-07-23 17:39:31 +00:00
committed by zzz
parent 9f4439583d
commit da4827f287
4 changed files with 26 additions and 11 deletions

View File

@ -160,7 +160,7 @@ public class Log {
return priority >= _minPriority;
}
String getName() {
public String getName() {
if (_class != null)
return _class.getName();
else

View File

@ -73,6 +73,7 @@ public class LogManager {
private int _defaultLimit;
private char[] _format;
private SimpleDateFormat _dateFormat;
private String _dateFormatPattern;
private String _baseLogfilename;
private int _fileSize;
private int _rotationLimit;
@ -127,6 +128,16 @@ public class LogManager {
updateLimit(rv);
return rv;
}
public List getLogs() {
List rv = null;
synchronized (_logs) {
rv = new ArrayList(_logs.size());
for (Iterator iter = _logs.values().iterator(); iter.hasNext(); ) {
rv.add(iter.next());
}
}
return rv;
}
void addLog(Log log) {
synchronized (_logs) {
if (!_logs.containsKey(log.getScope()))
@ -229,6 +240,7 @@ public class LogManager {
_format = fmt.toCharArray();
String df = config.getProperty(PROP_DATEFORMAT, DEFAULT_DATEFORMAT);
_dateFormatPattern = df;
_dateFormat = new SimpleDateFormat(df);
String disp = config.getProperty(PROP_DISPLAYONSCREEN);
@ -380,15 +392,15 @@ public class LogManager {
///
/// would be friend methods for LogWriter...
///
String _getBaseLogfilename() {
public String getBaseLogfilename() {
return _baseLogfilename;
}
int _getFileSize() {
public int getFileSize() {
return _fileSize;
}
int _getRotationLimit() {
public int getRotationLimit() {
return _rotationLimit;
}
@ -404,13 +416,16 @@ public class LogManager {
return vals;
}
char[] _getFormat() {
public char[] getFormat() {
return _format;
}
SimpleDateFormat _getDateFormat() {
public SimpleDateFormat getDateFormat() {
return _dateFormat;
}
public String getDateFormatPattern() {
return _dateFormatPattern;
}
public static void main(String args[]) {
I2PAppContext ctx = new I2PAppContext();

View File

@ -31,7 +31,7 @@ class LogRecordFormatter {
if (rec.getThrowable() != null)
size += 512;
StringBuffer buf = new StringBuffer(size);
char format[] = manager._getFormat();
char format[] = manager.getFormat();
for (int i = 0; i < format.length; ++i) {
switch ((int) format[i]) {
case (int) LogManager.DATE:
@ -75,7 +75,7 @@ class LogRecordFormatter {
}
private static String getWhen(LogManager manager, LogRecord logRecord) {
return manager._getDateFormat().format(new Date(logRecord.getDate()));
return manager.getDateFormat().format(new Date(logRecord.getDate()));
}
private static String getPriority(LogRecord rec) {

View File

@ -108,7 +108,7 @@ class LogWriter implements Runnable {
System.err.println("Error writing record, disk full?");
t.printStackTrace();
}
if (_numBytesInCurrentFile >= _manager._getFileSize()) {
if (_numBytesInCurrentFile >= _manager.getFileSize()) {
rotateFile();
}
}
@ -118,7 +118,7 @@ class LogWriter implements Runnable {
*
*/
private void rotateFile() {
String pattern = _manager._getBaseLogfilename();
String pattern = _manager.getBaseLogfilename();
File f = getNextFile(pattern);
_currentFile = f;
_numBytesInCurrentFile = 0;
@ -151,7 +151,7 @@ class LogWriter implements Runnable {
if (pattern.indexOf('#') < 0) {
return new File(pattern);
} else {
int max = _manager._getRotationLimit();
int max = _manager.getRotationLimit();
if (_rotationNum == -1) {
return getFirstFile(pattern, max);
} else {