FileDocCategorySizeDatePackage
LoggerImpl.javaAPI DocAzureus 3.0.3.44817Fri Mar 03 00:37:26 GMT 2006org.gudy.azureus2.pluginsimpl.local.logging

LoggerImpl

public class LoggerImpl extends Object implements org.gudy.azureus2.plugins.logging.Logger
author
parg

Fields Summary
private org.gudy.azureus2.plugins.PluginInterface
pi
private List
channels
private Map
alert_listeners_map
Constructors Summary
public LoggerImpl(org.gudy.azureus2.plugins.PluginInterface _pi)

	
	
	
			 
	
		pi	= _pi;
	
Methods Summary
public voidaddAlertListener(org.gudy.azureus2.plugins.logging.LoggerAlertListener listener)

		
		ILogAlertListener lg_listener = new ILogAlertListener() {
			public void alertRaised(LogAlert alert) {
				if (alert.err == null) {
					int type;

					if (alert.entryType == LogAlert.AT_INFORMATION) {
						type = LoggerChannel.LT_INFORMATION;
					} else if (alert.entryType == LogAlert.AT_WARNING) {
						type = LoggerChannel.LT_WARNING;
					} else {
						type = LoggerChannel.LT_ERROR;
					}

					listener.alertLogged(type, alert.text, alert.repeatable);

				} else
					listener.alertLogged(alert.text, alert.err, alert.repeatable);
			}

		};
				
		alert_listeners_map.put( listener, lg_listener );
		
		org.gudy.azureus2.core3.logging.Logger.addListener( lg_listener );
	
public voidaddFileLoggingListener(org.gudy.azureus2.plugins.logging.FileLoggerAdapter listener)

		FileLogging fileLogging = org.gudy.azureus2.core3.logging.Logger.getFileLoggingInstance();
		if (fileLogging == null)
			return;
		
		fileLogging.addListener(new PluginFileLoggerAdapater(fileLogging, listener));
	
public org.gudy.azureus2.plugins.logging.LoggerChannelgetChannel(java.lang.String name)

		LoggerChannel	channel = new LoggerChannelImpl( this, name, false, false );
		
		channels.add( channel );
		
		return( channel );
	
public org.gudy.azureus2.plugins.logging.LoggerChannel[]getChannels()

		LoggerChannel[]	res = new LoggerChannel[channels.size()];
		
		channels.toArray( res );
		
		return( res );
	
public org.gudy.azureus2.plugins.logging.LoggerChannelgetNullChannel(java.lang.String name)

		LoggerChannel	channel = new LoggerChannelImpl( this, name, true, true );
		
		channels.add( channel );
		
		return( channel );
	
public org.gudy.azureus2.plugins.PluginInterfacegetPluginInterface()

		return( pi );
	
public org.gudy.azureus2.plugins.logging.LoggerChannelgetTimeStampedChannel(java.lang.String name)

		LoggerChannel	channel = new LoggerChannelImpl( this, name, true, false );
		
		channels.add( channel );
		
		return( channel );
	
public voidremoveAlertListener(org.gudy.azureus2.plugins.logging.LoggerAlertListener listener)

		ILogAlertListener	lg_listener = (ILogAlertListener)alert_listeners_map.remove( listener );
		
		if ( lg_listener != null ){
			
			org.gudy.azureus2.core3.logging.Logger.removeListener( lg_listener );
		}
	
public voidremoveFileLoggingListener(org.gudy.azureus2.plugins.logging.FileLoggerAdapter listener)

		FileLogging fileLogging = org.gudy.azureus2.core3.logging.Logger.getFileLoggingInstance();
		if (fileLogging == null)
			return;

		// find listener and remove
		Object[] listeners = fileLogging.getListeners().toArray();
		for (int i = 0; i < listeners.length; i++) {
			if (listeners[i] instanceof PluginFileLoggerAdapater) {
				PluginFileLoggerAdapater l = (PluginFileLoggerAdapater) listeners[i];
				if (l.listener == listener) {
					fileLogging.removeListener(l);
				}
			}
		}