package org.jpos.util;


public class AppLogger implements LogSource{


	protected Logger logger = Logger.getLogger("Q2");
    protected String realm = null;
    protected String originalRealm = null;

	public  AppLogger() {
		super();
		setLogger (this.logger,"");
	}
	public void setLogger (Logger logger) {
        this.logger = logger;
    }
	
	public void setLogger(Logger logger, String realm){
		this.logger = logger;
		this.realm  = realm;
		if (originalRealm == null)
           originalRealm = realm;
		setLogger(logger);
	}
	
    public String getRealm () {
        return realm;
    }
    public Logger getLogger() {
        return logger;
    }

	public String getOriginalRealm() {
        return originalRealm == null ? 
            this.getClass().getName() : originalRealm;
    }

	public void log(String realm, String tag, Object msg ){
		this.realm  = realm;
		if (originalRealm == null)
			originalRealm = realm;

		LogEvent evt = new LogEvent (tag);
		evt.addMessage (msg);
		Logger.log(evt);
	}
	public void log(String tag, Object msg ){
		this.realm  = null;
		originalRealm = null;
		LogEvent evt = new LogEvent (tag);
		evt.addMessage (msg);
		Logger.log(evt);
	}
	public void log(Object msg ){
		//setLogger (this.logger,"");
	    LogEvent evt = new LogEvent ();
        evt.addMessage (msg);
		Logger.log(evt);
	}
	
	public void exceptionLog(Object msg ){
		//setLogger (this.logger,"");
	    LogEvent evt = new LogEvent (this,"exception");
        evt.addMessage (msg);
		Logger.log(evt);
	}	
}
