Methods Summary |
---|
public void | addListener(org.gudy.azureus2.core3.logging.ILogAlertListener l)
alertListeners.add(l);
for (int i = 0; i < alertHistory.size(); i++) {
LogAlert alert = (LogAlert) alertHistory.get(i);
l.alertRaised(alert);
}
|
public void | addListener(org.gudy.azureus2.core3.logging.ILogEventListener aListener)
logListeners.add(aListener);
|
public void | doRedirects()Set up stdout/stderr redirects
try {
if (System.out != psOut) {
if (psOldOut == null)
psOldOut = System.out;
psOut = new PrintStream(new RedirectorStream(psOldOut, LogIDs.STDOUT,
LogEvent.LT_INFORMATION));
System.setOut(psOut);
}
if (System.err != psErr) {
if (psOldErr == null)
psOldErr = System.err;
psErr = new PrintStream(new RedirectorStream(psOldErr, LogIDs.STDERR,
LogEvent.LT_ERROR));
System.setErr(psErr);
}
} catch (Throwable e) {
Debug.printStackTrace(e);
}
|
public java.io.PrintStream | getOldStdErr()
return psOldErr;
|
public void | init()Must be seperate from constructor, because the code may call a Logger.*
method, which requires a loggerImpl to be not null.
// temporarily set to true, to log any errors between now and setting
// bEnabled properly.
bEventLoggingEnabled = true;
// Shorten from COConfigurationManager To make code more readable
final ConfigurationManager config = ConfigurationManager.getInstance();
boolean overrideLog = System.getProperty("azureus.overridelog") != null;
if (overrideLog) {
bEventLoggingEnabled = true;
} else {
bEventLoggingEnabled = config.getBooleanParameter("Logger.Enabled");
config.addParameterListener("Logger.Enabled", new ParameterListener() {
public void parameterChanged(String parameterName) {
bEventLoggingEnabled = config.getBooleanParameter("Logger.Enabled");
}
});
}
alertLogger = AEDiagnostics.getLogger("alerts");
|
public boolean | isEnabled()
return bEventLoggingEnabled;
|
public void | log(org.gudy.azureus2.core3.logging.LogAlert alert)
String logText = "Alert:" + alert.entryType + ":" + alert.text;
// Log all Alerts as Events
LogEvent alertEvent = new LogEvent(LogIDs.ALERT, alert.entryType,
logText);
alertEvent.err = alert.err;
Logger.log(alertEvent);
if (alertLogger != null)
alertLogger.log(logText);
alertHistory.add(alert);
if (alertHistory.size() > MAXHISTORY)
alertHistory.remove(0);
for (int i = 0; i < alertListeners.size(); i++) {
try {
Object listener = alertListeners.get(i);
if (listener instanceof ILogAlertListener)
((ILogAlertListener) listener).alertRaised(alert);
} catch (Throwable f) {
if (psOldErr != null) {
psOldErr.println("Error while alerting: " + f.getMessage());
f.printStackTrace(psOldErr);
}
}
}
|
public void | log(org.gudy.azureus2.core3.logging.LogEvent event)Log an event
/**
* This highlights bits of code which log, but don't bother
* to check whether logging is enabled or not.
*/
//if (!bEventLoggingEnabled) {
// new Exception("No logging check done!").printStackTrace(psOldErr);
//}
if (bLogToStdOut && psOldOut != null)
psOldOut.println(event.text);
if (event.entryType == LogEvent.LT_ERROR) {
if ( AEDiagnostics.isStartupComplete()){
// more recursive horrors here if we try and log too early
Debug.outDiagLoggerOnly("[" + event.logID + "] " + event.text);
}
if (psOldErr != null && event.logID != LogIDs.STDERR) {
psOldErr.println("[" + event.logID + "] " + event.text);
}
}
if (bEventLoggingEnabled)
for (int i = 0; i < logListeners.size(); i++) {
try {
Object listener = logListeners.get(i);
if (listener instanceof ILogEventListener)
((ILogEventListener) listener).log(event);
} catch (Throwable e) {
if (psOldErr != null) {
psOldErr.println("Error while logging: " + e.getMessage());
e.printStackTrace(psOldErr);
}
}
}
// Write error to stderr, which will eventually get back here
if (event.err != null && event.entryType == LogEvent.LT_ERROR){
Debug.printStackTrace(event.err);
}
|
public void | logTextResource(org.gudy.azureus2.core3.logging.LogAlert alert)
alert.text = MessageText.getString(alert.text);
log(alert);
|
public void | logTextResource(org.gudy.azureus2.core3.logging.LogAlert alert, java.lang.String[] params)
alert.text = MessageText.getString(alert.text, params);
log(alert);
|
public void | logTextResource(org.gudy.azureus2.core3.logging.LogEvent event)
event.text = MessageText.getString(event.text);
log(event);
|
public void | logTextResource(org.gudy.azureus2.core3.logging.LogEvent event, java.lang.String[] params)
event.text = MessageText.getString(event.text, params);
log(event);
|
public void | removeListener(org.gudy.azureus2.core3.logging.ILogAlertListener l)
alertListeners.remove(l);
|
public void | removeListener(org.gudy.azureus2.core3.logging.ILogEventListener aListener)
logListeners.remove(aListener);
|