/*
 * Copyright 2014 Nastel Technologies, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.nastel.jkool.tnt4j.sink;

import java.util.EventObject;

import com.nastel.jkool.tnt4j.core.OpLevel;
import com.nastel.jkool.tnt4j.tracker.TrackingActivity;
import com.nastel.jkool.tnt4j.tracker.TrackingEvent;
import com.nastel.jkool.tnt4j.utils.Utils;

/**
 * <p>
 * An event class for reporting logging activities generated by an <code>EventSink</code> instance.
 * </p>
 * 
 * @see EventSink
 * @see TrackingEvent
 * @see TrackingActivity
 * @see OpLevel
 * 
 * @version $Revision: 3 $
 * 
 */
public class SinkLogEvent extends EventObject {
	private static final long serialVersionUID = 1L;

	private Object logObj = null;
	private Throwable error = null;
	private OpLevel level = OpLevel.NONE;
	private Object [] argList = null;

	/**
	 * Create a new log event instance
	 * 
	 * @param source
	 *            sink associated with the event
	 * @param msg
	 *            tracking event instance
	 */
	public SinkLogEvent(EventSink source, TrackingEvent msg) {
	    super(source);
	    logObj = msg;
	    error = msg.getOperation().getThrowable();
	    level = msg.getSeverity();
   }
	
	/**
	 * Create a new log event instance
	 * 
	 * @param source
	 *            sink associated with the event
	 * @param msg
	 *            tracking activity instance
	 */
	public SinkLogEvent(EventSink source, TrackingActivity msg) {
	    super(source);
	    logObj = msg;
	    error = msg.getThrowable();
    }
	
	/**
	 * Create a new log event instance. 
	 * 
	 * @param source
	 *            sink associated with the event
	 * @param sev
	 *            log severity
	 * @param msg
	 *            log message
	 * @param args
	 *            argument list associated with the message
	 */
	public SinkLogEvent(EventSink source, OpLevel sev, String msg, Object...args) {
	    super(source);
	    logObj = msg;
	    if (args != null && args.length > 0) {
	    	argList = args;
	    	error = Utils.getThrowable(args);
	    }    
	    level = sev;
	}
	
	/**
	 * Return associated event sink with this event
	 *
	 * @return event sink handle associated with this event
	 */
	public EventSink getEventSink() {
		return (EventSink) getSource();
	}
	
	/**
	 * Return list of arguments supplied with the logging message
	 *
	 * @return array of objects
	 */
	public Object [] getArguments() {
		return argList;
	}
	
	/**
	 * Return current severity level associated with this event
	 *
	 * @return severity level
	 */
	public OpLevel getSeverity() {
		return level;
	}
	
	/**
	 * Return log exception
	 *
	 * @return severity level
	 */
	public Throwable getException() {
		return error;
	}
	
	/**
	 * Return log object
	 *
	 * @return log object
	 */
	public Object getSinkObject() {
		return logObj;
	}
	
	@Override
	public String toString() {
		return super.toString() 
			+ "{source: " + getSource() 
			+ ", sev=" + level + ", log.obj=" + Utils.quote(logObj) + ", exception=" +  Utils.quote(error) + "}";
	}
}

@@ -2557,201 +2557,8 @@
 %09%7D%0A%09
-%0A%09/**%0A%09 * Return associated event sink with this event%0A%09 *%0A%09 * @return event sink handle associated with this event%0A%09 */%0A%09public EventSink getEventSink() %7B%0A%09%09return (EventSink) getSource();%0A%09%7D%0A
 %09%0A%09/

Revert "Updated sinklogevent"