forked from I2P_Developers/i2p.i2p
expose some data for the router console to query
This commit is contained in:
@ -160,7 +160,7 @@ public class Log {
|
|||||||
return priority >= _minPriority;
|
return priority >= _minPriority;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getName() {
|
public String getName() {
|
||||||
if (_class != null)
|
if (_class != null)
|
||||||
return _class.getName();
|
return _class.getName();
|
||||||
else
|
else
|
||||||
|
@ -73,6 +73,7 @@ public class LogManager {
|
|||||||
private int _defaultLimit;
|
private int _defaultLimit;
|
||||||
private char[] _format;
|
private char[] _format;
|
||||||
private SimpleDateFormat _dateFormat;
|
private SimpleDateFormat _dateFormat;
|
||||||
|
private String _dateFormatPattern;
|
||||||
private String _baseLogfilename;
|
private String _baseLogfilename;
|
||||||
private int _fileSize;
|
private int _fileSize;
|
||||||
private int _rotationLimit;
|
private int _rotationLimit;
|
||||||
@ -127,6 +128,16 @@ public class LogManager {
|
|||||||
updateLimit(rv);
|
updateLimit(rv);
|
||||||
return 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) {
|
void addLog(Log log) {
|
||||||
synchronized (_logs) {
|
synchronized (_logs) {
|
||||||
if (!_logs.containsKey(log.getScope()))
|
if (!_logs.containsKey(log.getScope()))
|
||||||
@ -229,6 +240,7 @@ public class LogManager {
|
|||||||
_format = fmt.toCharArray();
|
_format = fmt.toCharArray();
|
||||||
|
|
||||||
String df = config.getProperty(PROP_DATEFORMAT, DEFAULT_DATEFORMAT);
|
String df = config.getProperty(PROP_DATEFORMAT, DEFAULT_DATEFORMAT);
|
||||||
|
_dateFormatPattern = df;
|
||||||
_dateFormat = new SimpleDateFormat(df);
|
_dateFormat = new SimpleDateFormat(df);
|
||||||
|
|
||||||
String disp = config.getProperty(PROP_DISPLAYONSCREEN);
|
String disp = config.getProperty(PROP_DISPLAYONSCREEN);
|
||||||
@ -380,15 +392,15 @@ public class LogManager {
|
|||||||
///
|
///
|
||||||
/// would be friend methods for LogWriter...
|
/// would be friend methods for LogWriter...
|
||||||
///
|
///
|
||||||
String _getBaseLogfilename() {
|
public String getBaseLogfilename() {
|
||||||
return _baseLogfilename;
|
return _baseLogfilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _getFileSize() {
|
public int getFileSize() {
|
||||||
return _fileSize;
|
return _fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _getRotationLimit() {
|
public int getRotationLimit() {
|
||||||
return _rotationLimit;
|
return _rotationLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,13 +416,16 @@ public class LogManager {
|
|||||||
return vals;
|
return vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] _getFormat() {
|
public char[] getFormat() {
|
||||||
return _format;
|
return _format;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleDateFormat _getDateFormat() {
|
public SimpleDateFormat getDateFormat() {
|
||||||
return _dateFormat;
|
return _dateFormat;
|
||||||
}
|
}
|
||||||
|
public String getDateFormatPattern() {
|
||||||
|
return _dateFormatPattern;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
I2PAppContext ctx = new I2PAppContext();
|
I2PAppContext ctx = new I2PAppContext();
|
||||||
|
@ -31,7 +31,7 @@ class LogRecordFormatter {
|
|||||||
if (rec.getThrowable() != null)
|
if (rec.getThrowable() != null)
|
||||||
size += 512;
|
size += 512;
|
||||||
StringBuffer buf = new StringBuffer(size);
|
StringBuffer buf = new StringBuffer(size);
|
||||||
char format[] = manager._getFormat();
|
char format[] = manager.getFormat();
|
||||||
for (int i = 0; i < format.length; ++i) {
|
for (int i = 0; i < format.length; ++i) {
|
||||||
switch ((int) format[i]) {
|
switch ((int) format[i]) {
|
||||||
case (int) LogManager.DATE:
|
case (int) LogManager.DATE:
|
||||||
@ -75,7 +75,7 @@ class LogRecordFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getWhen(LogManager manager, LogRecord logRecord) {
|
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) {
|
private static String getPriority(LogRecord rec) {
|
||||||
|
@ -108,7 +108,7 @@ class LogWriter implements Runnable {
|
|||||||
System.err.println("Error writing record, disk full?");
|
System.err.println("Error writing record, disk full?");
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
if (_numBytesInCurrentFile >= _manager._getFileSize()) {
|
if (_numBytesInCurrentFile >= _manager.getFileSize()) {
|
||||||
rotateFile();
|
rotateFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ class LogWriter implements Runnable {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void rotateFile() {
|
private void rotateFile() {
|
||||||
String pattern = _manager._getBaseLogfilename();
|
String pattern = _manager.getBaseLogfilename();
|
||||||
File f = getNextFile(pattern);
|
File f = getNextFile(pattern);
|
||||||
_currentFile = f;
|
_currentFile = f;
|
||||||
_numBytesInCurrentFile = 0;
|
_numBytesInCurrentFile = 0;
|
||||||
@ -151,7 +151,7 @@ class LogWriter implements Runnable {
|
|||||||
if (pattern.indexOf('#') < 0) {
|
if (pattern.indexOf('#') < 0) {
|
||||||
return new File(pattern);
|
return new File(pattern);
|
||||||
} else {
|
} else {
|
||||||
int max = _manager._getRotationLimit();
|
int max = _manager.getRotationLimit();
|
||||||
if (_rotationNum == -1) {
|
if (_rotationNum == -1) {
|
||||||
return getFirstFile(pattern, max);
|
return getFirstFile(pattern, max);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user