package com.eactive.eai.transformer.util;

import com.eactive.eai.common.server.Keys;

/**
 * 
 */
public class Logger {
//    private String className;
    private com.eactive.eai.common.util.Logger logger;
    
    protected static boolean application;   

    static {
        String wlServer = System.getProperty(Keys.SERVER_KEY);
        if (wlServer == null) {
            //System.out.println("Standalone Application");
            application = true;
        } else {
            //System.out.println("WebLogic Application");
            application = false;
        }
    }
    
    private Logger(String clazzName) {
//        int idx = clazzName.lastIndexOf(".");
//
//        if (idx == -1) {
//            this.clazzName = clazzName;
//        } else {
//            this.clazzName = clazzName.substring(idx + 1);
//        }
        if(!application) {
            logger = com.eactive.eai.common.util.Logger.getLogger(com.eactive.eai.common.util.Logger.LOGGER_DEFAULT);
        } else {
            logger = com.eactive.eai.common.util.Logger.getLogger("transformer"); 
        }
    }

    public void debug(String message) {
        this.logger.debug(message);
    }

    public void info(String message) {
        this.logger.info(message);
    }

    public void warn(String message) {
        this.logger.warn(message);
    }

    public void warn(String message, Throwable t) {
        this.logger.warn(message, t);
    }

    public void error(String message) {
        this.logger.error(message);
    }
    
    public void error(String message, Throwable t) {
        this.logger.error(message,t);
    }

    public void fatal(String message) {
        this.logger.fatal(message);
    }

    public boolean isDebugEnabled() {
        return this.logger.isDebugEnabled();
    }

    public boolean isInfoEnabled() {
        return this.logger.isInfoEnabled();
    }

    public boolean isWarnEnabled() {
        return this.logger.isWarnEnabled();
    }
    
    public static Logger getLogger(Class clazz) {
        return new Logger(clazz.getName());
    }

    public static Logger getLogger() {
        return new Logger("");
    }
    
    public static Logger getLogger(String name) {
        return new Logger(name);
    }
}
