FileDocCategorySizeDatePackage
Logger.javaAPI DocAzureus 3.0.3.45137Tue Sep 04 14:09:00 BST 2007org.gudy.azureus2.core3.logging

Logger

public class Logger extends Object
A static implementation of the LoggerImpl class.
note
Currently, LoggerImpl and Logger could be combined, but they are split for future consideration (ie. allowing multiple LoggerImpl)
author
TuxPaper
since
2.3.0.7

Fields Summary
private static final LogIDs
LOGID
private static org.gudy.azureus2.core3.logging.impl.LoggerImpl
loggerImpl
private static org.gudy.azureus2.core3.logging.impl.FileLogging
fileLogging
Constructors Summary
Methods Summary
public static voidaddListener(ILogAlertListener aListener)
Add a listener that's triggered when an alert is logged.

param
aListener Listener to call when an alert is logged

		loggerImpl.addListener(aListener);
	
public static voidaddListener(ILogEventListener aListener)
Add a listener that's triggered when an event is logged.

param
aListener Listener to call when an event is logged

		loggerImpl.addListener(aListener);
	
public static voiddoRedirects()
Redirect stdout and stderr to Logger.

		loggerImpl.doRedirects();
	
public static org.gudy.azureus2.core3.logging.impl.FileLogginggetFileLoggingInstance()

		return fileLogging;
	
public static java.io.PrintStreamgetOldStdErr()
Retrieve the original stderr output before we hooked it. Handy for printing out critical errors that need to bypass the logger capture.

return
stderr

		return loggerImpl.getOldStdErr();
	
public static booleanisEnabled()
Determines whether events are logged

return
true if events are logged


	 
		try {
			loggerImpl = new LoggerImpl();
			loggerImpl.init();

			fileLogging.initialize();

			if (loggerImpl.isEnabled()) {
				log(new LogEvent(LOGID, "**** Logging starts: "
					+ Constants.AZUREUS_VERSION + " ****"));

				log(new LogEvent(LOGID, "java.home=" + System.getProperty("java.home")));

				log(new LogEvent(LOGID, "java.version="
					+ System.getProperty("java.version")));

				log(new LogEvent(LOGID, "os=" + System.getProperty("os.arch") + "/"
					+ System.getProperty("os.name") + "/"
					+ System.getProperty("os.version")));

				log(new LogEvent(LOGID, "user.dir=" + System.getProperty("user.dir")));

				log(new LogEvent(LOGID, "user.home=" + System.getProperty("user.home")));
			}
		} catch (Throwable t) {
			t.printStackTrace();
			Debug.out("Error initializing Logger", t);
			// loggerImpl will always be set, except for cases where there wasn't
			// enough memory. In that case, app will blork with null pointer exception
			// on first Logger.* call.  However, since there's not enough memory,
			// application will probably blork somewhere else in the code first. 
		}
	
		return loggerImpl.isEnabled();
	
public static voidlog(LogEvent event)
Log an event

param
event event to log

		loggerImpl.log(event);
	
public static voidlog(LogAlert alert)

		loggerImpl.log(alert);
	
public static voidlogTextResource(LogEvent event)
Log an event, loading text from out messagebundle. Fill event.text with resource id.

param
event event to log

		loggerImpl.logTextResource(event);
	
public static voidlogTextResource(LogEvent event, java.lang.String[] params)

		loggerImpl.logTextResource(event, params);
	
public static voidlogTextResource(LogAlert alert)

		loggerImpl.logTextResource(alert);
	
public static voidlogTextResource(LogAlert alert, java.lang.String[] params)

		loggerImpl.logTextResource(alert, params);
	
public static voidremoveListener(ILogEventListener aListener)
Remove a previously added log listener

param
aListener Listener to remove

		loggerImpl.removeListener(aListener);
	
public static voidremoveListener(ILogAlertListener aListener)
Remove a previously added log listener

param
aListener Listener to remove

		loggerImpl.removeListener(aListener);