//------------------------------------------------------------------------------
// <copyright file="SOATraceSource.java" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
// <summary>
//      SOA Tracing functions.
// </summary>
//------------------------------------------------------------------------------


package com.microsoft.hpc.SOATrace;

import java.io.IOException;
import java.util.logging.*;


/**
 * the helper functions for the log.
 * 
 * (doesn't quite work, Apache CXF may be interfering)
 */
public class SOATraceSource
{
    /**
     * the real trace source.
     */
    private Logger traceSourceField;
    
    /**
     * the event source
     */
    private String eventSourceField;
    
    /**
     * the session id.
     */
    private String sessionIdField;
    
    private static FileHandler fh = null;
    
    /**
     * Initializes a new instance of the SOATraceSource class
     * 
     * @param traceSourceName - the trace source name
     * @param eventSource - indicating the event source
     * @throws IOException 
     * @throws SecurityException 
     */
    public SOATraceSource(String traceSourceName, String eventSource)
    {       
        if(fh == null) //ensures that only one tracelog file will be created at a time
        {
            ;//fh = new FileHandler("tracelog.txt"); //should we write to a file?
            //fh.setFormatter(new SimpleFormatter()); //allows to be changable in logging.properties
        }
        this.traceSourceField = Logger.getLogger(traceSourceName);
        this.eventSourceField = eventSource;
    }
    
    /**
     * Initializes a new instance of the SOATraceSource class.
     * @param sessionId - the session id
     * @param traceSourceName - the trace source name
     * @param eventSource - indicating the event source
     * @throws IOException 
     * @throws SecurityException 
     */
    public SOATraceSource(String sessionId, String traceSourceName, String eventSource)
    {
        this(traceSourceName, eventSource);
        this.sessionIdField = sessionId;
    }
    
    /**
     * Gets the trace source
     * @return
     */
    public Logger getTraceSource()
    {
        return traceSourceField;
    }
    
    /**
     * Gets the event source
     * @return
     */
    public String getEventSource()
    {
        return eventSourceField;
    }

    /**
     * Gets the session id
     * @return
     */
    public String getSessionId()
    {
        return sessionIdField;
    }
}
