STPServiceLogger.java 5.35 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.fd.stp.internal.logging;

import java.util.ResourceBundle;
import java.util.StringTokenizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class STPServiceLogger {
    ResourceBundle bundle;
    Logger logger;
    private static String LOGGING_BUNDLE = "com.adobe.fd.stp.internal.logging.STPService";

    public STPServiceLogger(Class clazz) {
        this.logger = LoggerFactory.getLogger((Class)clazz);
        this.bundle = ResourceBundle.getBundle(this.getLoggingBundle());
    }

    protected String getLoggingBundle() {
        return LOGGING_BUNDLE;
    }

    public String formatMsg(String format, Object[] args) {
        StringBuffer sb = new StringBuffer();
        if (format != null) {
            StringTokenizer st = new StringTokenizer(format, "{}");
            boolean counter = false;
            int argPos = format.indexOf("{}");
            int index = 0;
            if (args != null && argPos > -1) {
                sb.append(format.substring(0, argPos));
                while (argPos < format.length() && argPos >= 0 && index < args.length) {
                    sb.append(args[index++]);
                    int argPos2 = format.indexOf("{}", argPos + 1);
                    sb.append(format.substring(argPos + 2, argPos2 > -1 ? argPos2 : format.length()));
                    argPos = argPos2;
                }
            }
        }
        return sb.toString();
    }

    public String msgToLog(String msg) {
        try {
            if (this.bundle != null && this.bundle.getObject(msg) != null) {
                return msg + ":" + (String)this.bundle.getObject(msg);
            }
        }
        catch (Exception e) {
            this.logger.trace("Exception while reading resource " + msg + " from " + this.getLoggingBundle(), (Throwable)e);
        }
        return msg;
    }

    public void warn(String msg) {
        msg = this.msgToLog(msg);
        this.logger.warn(msg);
    }

    public void warn(String msg, String arg1) {
        msg = this.msgToLog(msg);
        this.logger.warn(msg, (Object)arg1);
    }

    public void warn(String msg, String arg1, String arg2) {
        msg = this.msgToLog(msg);
        this.logger.warn(msg, (Object)arg1, (Object)arg2);
    }

    public void warn(String msg, Object[] args) {
        msg = this.msgToLog(msg);
        this.logger.warn(msg, args);
    }

    public void warn(String msg, Object[] args, Throwable t) {
        msg = this.formatMsg(this.msgToLog(msg), args);
        this.logger.warn(msg, t);
    }

    public void error(String msg) {
        msg = this.msgToLog(msg);
        this.logger.error(msg);
    }

    public void error(String msg, String arg1) {
        msg = this.msgToLog(msg);
        this.logger.error(msg, (Object)arg1);
    }

    public void error(String msg, String arg1, String arg2) {
        msg = this.msgToLog(msg);
        this.logger.error(msg, (Object)arg1, (Object)arg2);
    }

    public void error(String msg, Object[] args) {
        msg = this.msgToLog(msg);
        this.logger.error(msg, args);
    }

    public void error(String msg, Object[] args, Throwable t) {
        msg = this.formatMsg(this.msgToLog(msg), args);
        this.logger.error(msg, t);
    }

    public void debug(String msg) {
        msg = this.msgToLog(msg);
        this.logger.debug(msg);
    }

    public void debug(String msg, String arg1) {
        msg = this.msgToLog(msg);
        this.logger.debug(msg, (Object)arg1);
    }

    public void debug(String msg, String arg1, String arg2) {
        msg = this.msgToLog(msg);
        this.logger.debug(msg, (Object)arg1, (Object)arg2);
    }

    public void debug(String msg, Object[] args) {
        msg = this.msgToLog(msg);
        this.logger.debug(msg, args);
    }

    public void debug(String msg, Object[] args, Throwable t) {
        msg = this.formatMsg(this.msgToLog(msg), args);
        this.logger.debug(msg, t);
    }

    public void info(String msg) {
        msg = this.msgToLog(msg);
        this.logger.info(msg);
    }

    public void info(String msg, String arg1) {
        msg = this.msgToLog(msg);
        this.logger.info(msg, (Object)arg1);
    }

    public void info(String msg, String arg1, String arg2) {
        msg = this.msgToLog(msg);
        this.logger.info(msg, (Object)arg1, (Object)arg2);
    }

    public void info(String msg, Object[] args) {
        msg = this.msgToLog(msg);
        this.logger.info(msg, args);
    }

    public void info(String msg, Object[] args, Throwable t) {
        msg = this.formatMsg(this.msgToLog(msg), args);
        this.logger.info(msg, t);
    }

    public void trace(String msg) {
        msg = this.msgToLog(msg);
        this.logger.trace(msg);
    }

    public void trace(String msg, String arg1) {
        msg = this.msgToLog(msg);
        this.logger.trace(msg, (Object)arg1);
    }

    public void trace(String msg, String arg1, String arg2) {
        msg = this.msgToLog(msg);
        this.logger.trace(msg, (Object)arg1, (Object)arg2);
    }

    public void trace(String msg, Object[] args) {
        msg = this.msgToLog(msg);
        this.logger.trace(msg, args);
    }

    public void trace(String msg, Object[] args, Throwable t) {
        msg = this.formatMsg(this.msgToLog(msg), args);
        this.logger.trace(msg, t);
    }
}