com.crashlytics.tools.android_2.1.0

ception ex)
        {
          if (classLoader == thisClassLoader)
          {
            if (isDiagnosticsEnabled()) {
              logDiagnostic("Unable to locate any class called '" + factoryClass + "' via classloader " + objectId(classLoader));
            }
            throw ex;
          }
        }
        catch (NoClassDefFoundError e)
        {
          if (classLoader == thisClassLoader)
          {
            if (isDiagnosticsEnabled()) {
              logDiagnostic("Class '" + factoryClass + "' cannot be loaded" + " via classloader " + objectId(classLoader) + " - it depends on some other class that cannot be found.");
            }
            throw e;
          }
        }
        catch (ClassCastException e)
        {
          if (classLoader == thisClassLoader)
          {
            boolean implementsLogFactory = implementsLogFactory(logFactoryClass);
            
            StringBuffer msg = new StringBuffer();
            msg.append("The application has specified that a custom LogFactory implementation ");
            msg.append("should be used but Class '");
            msg.append(factoryClass);
            msg.append("' cannot be converted to '");
            msg.append(LogFactory.class.getName());
            msg.append("'. ");
            if (implementsLogFactory)
            {
              msg.append("The conflict is caused by the presence of multiple LogFactory classes ");
              msg.append("in incompatible classloaders. ");
              msg.append("Background can be found in http://commons.apache.org/logging/tech.html. ");
              msg.append("If you have not explicitly specified a custom LogFactory then it is likely ");
              msg.append("that the container has set one without your knowledge. ");
              msg.append("In this case, consider using the commons-logging-adapters.jar file or ");
              msg.append("specifying the standard LogFactory from the command line. ");
            }
            else
            {
              msg.append("Please check the custom implementation. ");
            }
            msg.append("Help can be found @http://commons.apache.org/logging/troubleshooting.html.");
            if (isDiagnosticsEnabled()) {
              logDiagnostic(msg.toString());
            }
            throw new ClassCastException(msg.toString());
          }
        }
      }
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Unable to load factory class via classloader " + objectId(classLoader) + " - trying the classloader associated with this LogFactory.");
      }
      logFactoryClass = Class.forName(factoryClass);
      return (LogFactory)logFactoryClass.newInstance();
    }
    catch (Exception e)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("Unable to create LogFactory instance.");
      }
      if ((logFactoryClass != null) && (!LogFactory.class.isAssignableFrom(logFactoryClass))) {
        return new LogConfigurationException("The chosen LogFactory implementation does not extend LogFactory. Please check your configuration.", e);
      }
      return new LogConfigurationException(e);
    }
  }
  
  private static boolean implementsLogFactory(Class logFactoryClass)
  {
    boolean implementsLogFactory = false;
    if (logFactoryClass != null) {
      try
      {
        ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader();
        if (logFactoryClassLoader == null)
        {
          logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader");
        }
        else
        {
          logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
          Class factoryFromCustomLoader = Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader);
          
          implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
          if (implementsLogFactory) {
            logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " implements LogFactory but was loaded by an incompatible classloader.");
          } else {
            logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " does not implement LogFactory.");
          }
        }
      }
      catch (SecurityException e)
      {
        logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether the compatibility was caused by a classloader conflict: " + e.getMessage());
      }
      catch (LinkageError e)
      {
        logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether the compatibility was caused by a classloader conflict: " + e.getMessage());
      }
      catch (ClassNotFoundException e)
      {
        logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded the custom LogFactory implementation. Is the custom factory in the right classloader?");
      }
    }
    return implementsLogFactory;
  }
  
  private static InputStream getResourceAsStream(ClassLoader loader, String name)
  {
    (InputStream)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final ClassLoader val$loader;
      private final String val$name;
      
      public Object run()
      {
        if (val$loader != null) {
          return val$loader.getResourceAsStream(val$name);
        }
        return ClassLoader.getSystemResourceAsStream(val$name);
      }
    });
  }
  
  private static Enumeration getResources(ClassLoader loader, String name)
  {
    PrivilegedAction action = new PrivilegedAction()
    {
      private final ClassLoader val$loader;
      private final String val$name;
      
      public Object run()
      {
        try
        {
          if (val$loader != null) {
            return val$loader.getResources(val$name);
          }
          return ClassLoader.getSystemResources(val$name);
        }
        catch (IOException e)
        {
          if (LogFactory.isDiagnosticsEnabled()) {
            LogFactory.logDiagnostic("Exception while trying to find configuration file " + val$name + ":" + e.getMessage());
          }
          return null;
        }
        catch (NoSuchMethodError e) {}
        return null;
      }
    };
    Object result = AccessController.doPrivileged(action);
    return (Enumeration)result;
  }
  
  private static Properties getProperties(URL url)
  {
    PrivilegedAction action = new PrivilegedAction()
    {
      private final URL val$url;
      
      public Object run()
      {
        InputStream stream = null;
        try
        {
          URLConnection connection = val$url.openConnection();
          connection.setUseCaches(false);
          stream = connection.getInputStream();
          if (stream != null)
          {
            Properties props = new Properties();
            props.load(stream);
            stream.close();
            stream = null;
            return props;
          }
          return null;
        }
        catch (IOException e)
        {
          if (LogFactory.isDiagnosticsEnabled()) {
            LogFactory.logDiagnostic("Unable to read URL " + val$url);
          }
        }
        finally
        {
          if (stream != null) {
            try
            {
              stream.close();
            }
            catch (IOException e)
            {
              if (LogFactory.isDiagnosticsEnabled()) {
                LogFactory.logDiagnostic("Unable to close stream for URL " + val$url);
              }
            }
          }
        }
      }
    };
    return (Properties)AccessController.doPrivileged(action);
  }
  
  private static final Properties getConfigurationFile(ClassLoader classLoader, String fileName)
  {
    Properties props = null;
    double priority = 0.0D;
    URL propsUrl = null;
    try
    {
      Enumeration urls = getResources(classLoader, fileName);
      if (urls == null) {
        return null;
      }
      while (urls.hasMoreElements())
      {
        URL url = (URL)urls.nextElement();
        
        Properties newProps = getProperties(url);
        if (newProps != null) {
          if (props == null)
          {
            propsUrl = url;
            props = newProps;
            String priorityStr = props.getProperty("priority");
            priority = 0.0D;
            if (priorityStr != null) {
              priority = Double.parseDouble(priorityStr);
            }
            if (isDiagnosticsEnabled()) {
              logDiagnostic("[LOOKUP] Properties file found at '" + url + "'" + " with priority " + priority);
            }
          }
          else
          {
            String newPriorityStr = newProps.getProperty("priority");
            double newPriority = 0.0D;
            if (newPriorityStr != null) {
              newPriority = Double.parseDouble(newPriorityStr);
            }
            if (newPriority > priority)
            {
              if (isDiagnosticsEnabled()) {
                logDiagnostic("[LOOKUP] Properties file at '" + url + "'" + " with priority " + newPriority + " overrides file at '" + propsUrl + "'" + " with priority " + priority);
              }
              propsUrl = url;
              props = newProps;
              priority = newPriority;
            }
            else if (isDiagnosticsEnabled())
            {
              logDiagnostic("[LOOKUP] Properties file at '" + url + "'" + " with priority " + newPriority + " does not override file at '" + propsUrl + "'" + " with priority " + priority);
            }
          }
        }
      }
    }
    catch (SecurityException e)
    {
      if (isDiagnosticsEnabled()) {
        logDiagnostic("SecurityException thrown while trying to find/read config files.");
      }
    }
    if (isDiagnosticsEnabled()) {
      if (props == null) {
        logDiagnostic("[LOOKUP] No properties file of name '" + fileName + "' found.");
      } else {
        logDiagnostic("[LOOKUP] Properties file of name '" + fileName + "' found at '" + propsUrl + '"');
      }
    }
    return props;
  }
  
  private static String getSystemProperty(String key, String def)
    throws SecurityException
  {
    (String)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final String val$key;
      private final String val$def;
      
      public Object run()
      {
        return System.getProperty(val$key, val$def);
      }
    });
  }
  
  private static PrintStream initDiagnostics()
  {
    String dest;
    try
    {
      dest = getSystemProperty("org.apache.commons.logging.diagnostics.dest", null);
      if (dest == null) {
        return null;
      }
    }
    catch (SecurityException ex)
    {
      return null;
    }
    if (dest.equals("STDOUT")) {
      return System.out;
    }
    if (dest.equals("STDERR")) {
      return System.err;
    }
    try
    {
      FileOutputStream fos = new FileOutputStream(dest, true);
      return new PrintStream(fos);
    }
    catch (IOException ex) {}
    return null;
  }
  
  protected static boolean isDiagnosticsEnabled()
  {
    return diagnosticsStream != null;
  }
  
  private static final void logDiagnostic(String msg)
  {
    if (diagnosticsStream != null)
    {
      diagnosticsStream.print(diagnosticPrefix);
      diagnosticsStream.println(msg);
      diagnosticsStream.flush();
    }
  }
  
  protected static final void logRawDiagnostic(String msg)
  {
    if (diagnosticsStream != null)
    {
      diagnosticsStream.println(msg);
      diagnosticsStream.flush();
    }
  }
  
  private static void logClassLoaderEnvironment(Class clazz)
  {
    if (!isDiagnosticsEnabled()) {
      return;
    }
    try
    {
      logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir"));
      logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path"));
    }
    catch (SecurityException ex)
    {
      logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths.");
    }
    String className = clazz.getName();
    ClassLoader classLoader;
    try
    {
      classLoader = getClassLoader(clazz);
    }
    catch (SecurityException ex)
    {
      logDiagnostic("[ENV] Security forbids determining the classloader for " + className);
      return;
    }
    logDiagnostic("[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader));
    logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader);
  }
  
  private static void logHierarchy(String prefix, ClassLoader classLoader)
  {
    if (!isDiagnosticsEnabled()) {
      return;
    }
    if (classLoader != null)
    {
      String classLoaderString = classLoader.toString();
      logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'");
    }
    ClassLoader systemClassLoader;
    try
    {
      systemClassLoader = ClassLoader.getSystemClassLoader();
    }
    catch (SecurityException ex)
    {
      logDiagnostic(prefix + "Security forbids determining the system classloader.");
      return;
    }
    if (classLoader != null)
    {
      StringBuffer buf = new StringBuffer(prefix + "ClassLoader tree:");
      do
      {
        buf.append(objectId(classLoader));
        if (classLoader == systemClassLoader) {
          buf.append(" (SYSTEM) ");
        }
        try
        {
          classLoader = classLoader.getParent();
        }
        catch (SecurityException ex)
        {
          buf.append(" --> SECRET");
          break;
        }
        buf.append(" --> ");
      } while (classLoader != null);
      buf.append("BOOT");
      
      logDiagnostic(buf.toString());
    }
  }
  
  public static String objectId(Object o)
  {
    if (o == null) {
      return "null";
    }
    return o.getClass().getName() + "@" + System.identityHashCode(o);
  }
  
  static
  {
    thisClassLoader = getClassLoader(LogFactory.class);
    String classLoaderName;
    try
    {
      ClassLoader classLoader = thisClassLoader;
      String classLoaderName;
      if (thisClassLoader == null) {
        classLoaderName = "BOOTLOADER";
      } else {
        classLoaderName = objectId(classLoader);
      }
    }
    catch (SecurityException e)
    {
      classLoaderName = "UNKNOWN";
    }
    diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
    diagnosticsStream = initDiagnostics();
    logClassLoaderEnvironment(LogFactory.class);
    factories = createFactoryStore();
    if (isDiagnosticsEnabled()) {
      logDiagnostic("BOOTSTRAP COMPLETED");
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.LogFactory
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging;

import java.lang.reflect.Constructor;
import java.util.Hashtable;
import java.util.Set;
import org.apache.commons.logging.impl.NoOpLog;

/**
 * @deprecated
 */
public class LogSource
{
  protected static Hashtable logs = new Hashtable();
  protected static boolean log4jIsAvailable = false;
  protected static boolean jdk14IsAvailable = false;
  protected static Constructor logImplctor = null;
  
  static
  {
    try
    {
      log4jIsAvailable = null != Class.forName("org.apache.log4j.Logger");
    }
    catch (Throwable t)
    {
      log4jIsAvailable = false;
    }
    try
    {
      jdk14IsAvailable = (null != Class.forName("java.util.logging.Logger")) && (null != Class.forName("org.apache.commons.logging.impl.Jdk14Logger"));
    }
    catch (Throwable t)
    {
      jdk14IsAvailable = false;
    }
    String name = null;
    try
    {
      name = System.getProperty("org.apache.commons.logging.log");
      if (name == null) {
        name = System.getProperty("org.apache.commons.logging.Log");
      }
    }
    catch (Throwable t) {}
    if (name != null) {
      try
      {
        setLogImplementation(name);
      }
      catch (Throwable t)
      {
        try
        {
          setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
        }
        catch (Throwable u) {}
      }
    } else {
      try
      {
        if (log4jIsAvailable) {
          setLogImplementation("org.apache.commons.logging.impl.Log4JLogger");
        } else if (jdk14IsAvailable) {
          setLogImplementation("org.apache.commons.logging.impl.Jdk14Logger");
        } else {
          setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
        }
      }
      catch (Throwable t)
      {
        try
        {
          setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
        }
        catch (Throwable u) {}
      }
    }
  }
  
  public static void setLogImplementation(String classname)
    throws LinkageError, NoSuchMethodException, SecurityException, ClassNotFoundException
  {
    try
    {
      Class logclass = Class.forName(classname);
      Class[] argtypes = new Class[1];
      argtypes[0] = "".getClass();
      logImplctor = logclass.getConstructor(argtypes);
    }
    catch (Throwable t)
    {
      logImplctor = null;
    }
  }
  
  public static void setLogImplementation(Class logclass)
    throws LinkageError, ExceptionInInitializerError, NoSuchMethodException, SecurityException
  {
    Class[] argtypes = new Class[1];
    argtypes[0] = "".getClass();
    logImplctor = logclass.getConstructor(argtypes);
  }
  
  public static Log getInstance(String name)
  {
    Log log = (Log)logs.get(name);
    if (null == log)
    {
      log = makeNewLogInstance(name);
      logs.put(name, log);
    }
    return log;
  }
  
  public static Log getInstance(Class clazz)
  {
    return getInstance(clazz.getName());
  }
  
  public static Log makeNewLogInstance(String name)
  {
    Log log;
    try
    {
      Object[] args = { name };
      log = (Log)logImplctor.newInstance(args);
    }
    catch (Throwable t)
    {
      log = null;
    }
    if (null == log) {
      log = new NoOpLog(name);
    }
    return log;
  }
  
  public static String[] getLogNames()
  {
    return (String[])logs.keySet().toArray(new String[logs.size()]);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.LogSource
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.logging.Log;

public class AvalonLogger
  implements Log
{
  private static volatile Logger defaultLogger = null;
  private final transient Logger logger;
  
  public AvalonLogger(Logger logger)
  {
    this.logger = logger;
  }
  
  public AvalonLogger(String name)
  {
    if (defaultLogger == null) {
      throw new NullPointerException("default logger has to be specified if this constructor is used!");
    }
    logger = defaultLogger.getChildLogger(name);
  }
  
  public Logger getLogger()
  {
    return logger;
  }
  
  public static void setDefaultLogger(Logger logger)
  {
    defaultLogger = logger;
  }
  
  public void debug(Object message, Throwable t)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message), t);
    }
  }
  
  public void debug(Object message)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message));
    }
  }
  
  public void error(Object message, Throwable t)
  {
    if (getLogger().isErrorEnabled()) {
      getLogger().error(String.valueOf(message), t);
    }
  }
  
  public void error(Object message)
  {
    if (getLogger().isErrorEnabled()) {
      getLogger().error(String.valueOf(message));
    }
  }
  
  public void fatal(Object message, Throwable t)
  {
    if (getLogger().isFatalErrorEnabled()) {
      getLogger().fatalError(String.valueOf(message), t);
    }
  }
  
  public void fatal(Object message)
  {
    if (getLogger().isFatalErrorEnabled()) {
      getLogger().fatalError(String.valueOf(message));
    }
  }
  
  public void info(Object message, Throwable t)
  {
    if (getLogger().isInfoEnabled()) {
      getLogger().info(String.valueOf(message), t);
    }
  }
  
  public void info(Object message)
  {
    if (getLogger().isInfoEnabled()) {
      getLogger().info(String.valueOf(message));
    }
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isErrorEnabled();
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isFatalErrorEnabled();
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isWarnEnabled();
  }
  
  public void trace(Object message, Throwable t)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message), t);
    }
  }
  
  public void trace(Object message)
  {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug(String.valueOf(message));
    }
  }
  
  public void warn(Object message, Throwable t)
  {
    if (getLogger().isWarnEnabled()) {
      getLogger().warn(String.valueOf(message), t);
    }
  }
  
  public void warn(Object message)
  {
    if (getLogger().isWarnEnabled()) {
      getLogger().warn(String.valueOf(message));
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.AvalonLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.apache.commons.logging.Log;

public class Jdk13LumberjackLogger
  implements Log, Serializable
{
  private static final long serialVersionUID = -8649807923527610591L;
  protected transient Logger logger = null;
  protected String name = null;
  private String sourceClassName = "unknown";
  private String sourceMethodName = "unknown";
  private boolean classAndMethodFound = false;
  protected static final Level dummyLevel = Level.FINE;
  
  public Jdk13LumberjackLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  private void log(Level level, String msg, Throwable ex)
  {
    if (getLogger().isLoggable(level))
    {
      LogRecord record = new LogRecord(level, msg);
      if (!classAndMethodFound) {
        getClassAndMethod();
      }
      record.setSourceClassName(sourceClassName);
      record.setSourceMethodName(sourceMethodName);
      if (ex != null) {
        record.setThrown(ex);
      }
      getLogger().log(record);
    }
  }
  
  private void getClassAndMethod()
  {
    try
    {
      Throwable throwable = new Throwable();
      throwable.fillInStackTrace();
      StringWriter stringWriter = new StringWriter();
      PrintWriter printWriter = new PrintWriter(stringWriter);
      throwable.printStackTrace(printWriter);
      String traceString = stringWriter.getBuffer().toString();
      StringTokenizer tokenizer = new StringTokenizer(traceString, "\n");
      
      tokenizer.nextToken();
      String line = tokenizer.nextToken();
      while (line.indexOf(getClass().getName()) == -1) {
        line = tokenizer.nextToken();
      }
      while (line.indexOf(getClass().getName()) >= 0) {
        line = tokenizer.nextToken();
      }
      int start = line.indexOf("at ") + 3;
      int end = line.indexOf('(');
      String temp = line.substring(start, end);
      int lastPeriod = temp.lastIndexOf('.');
      sourceClassName = temp.substring(0, lastPeriod);
      sourceMethodName = temp.substring(lastPeriod + 1);
    }
    catch (Exception ex) {}
    classAndMethodFound = true;
  }
  
  public void debug(Object message)
  {
    log(Level.FINE, String.valueOf(message), null);
  }
  
  public void debug(Object message, Throwable exception)
  {
    log(Level.FINE, String.valueOf(message), exception);
  }
  
  public void error(Object message)
  {
    log(Level.SEVERE, String.valueOf(message), null);
  }
  
  public void error(Object message, Throwable exception)
  {
    log(Level.SEVERE, String.valueOf(message), exception);
  }
  
  public void fatal(Object message)
  {
    log(Level.SEVERE, String.valueOf(message), null);
  }
  
  public void fatal(Object message, Throwable exception)
  {
    log(Level.SEVERE, String.valueOf(message), exception);
  }
  
  public Logger getLogger()
  {
    if (logger == null) {
      logger = Logger.getLogger(name);
    }
    return logger;
  }
  
  public void info(Object message)
  {
    log(Level.INFO, String.valueOf(message), null);
  }
  
  public void info(Object message, Throwable exception)
  {
    log(Level.INFO, String.valueOf(message), exception);
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isLoggable(Level.FINE);
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isLoggable(Level.SEVERE);
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isLoggable(Level.SEVERE);
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isLoggable(Level.INFO);
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isLoggable(Level.FINEST);
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isLoggable(Level.WARNING);
  }
  
  public void trace(Object message)
  {
    log(Level.FINEST, String.valueOf(message), null);
  }
  
  public void trace(Object message, Throwable exception)
  {
    log(Level.FINEST, String.valueOf(message), exception);
  }
  
  public void warn(Object message)
  {
    log(Level.WARNING, String.valueOf(message), null);
  }
  
  public void warn(Object message, Throwable exception)
  {
    log(Level.WARNING, String.valueOf(message), exception);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Jdk13LumberjackLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.logging.Log;

public class Jdk14Logger
  implements Log, Serializable
{
  private static final long serialVersionUID = 4784713551416303804L;
  protected static final Level dummyLevel = Level.FINE;
  
  public Jdk14Logger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  protected transient Logger logger = null;
  protected String name = null;
  
  protected void log(Level level, String msg, Throwable ex)
  {
    Logger logger = getLogger();
    if (logger.isLoggable(level))
    {
      Throwable dummyException = new Throwable();
      StackTraceElement[] locations = dummyException.getStackTrace();
      
      String cname = name;
      String method = "unknown";
      if ((locations != null) && (locations.length > 2))
      {
        StackTraceElement caller = locations[2];
        method = caller.getMethodName();
      }
      if (ex == null) {
        logger.logp(level, cname, method, msg);
      } else {
        logger.logp(level, cname, method, msg, ex);
      }
    }
  }
  
  public void debug(Object message)
  {
    log(Level.FINE, String.valueOf(message), null);
  }
  
  public void debug(Object message, Throwable exception)
  {
    log(Level.FINE, String.valueOf(message), exception);
  }
  
  public void error(Object message)
  {
    log(Level.SEVERE, String.valueOf(message), null);
  }
  
  public void error(Object message, Throwable exception)
  {
    log(Level.SEVERE, String.valueOf(message), exception);
  }
  
  public void fatal(Object message)
  {
    log(Level.SEVERE, String.valueOf(message), null);
  }
  
  public void fatal(Object message, Throwable exception)
  {
    log(Level.SEVERE, String.valueOf(message), exception);
  }
  
  public Logger getLogger()
  {
    if (logger == null) {
      logger = Logger.getLogger(name);
    }
    return logger;
  }
  
  public void info(Object message)
  {
    log(Level.INFO, String.valueOf(message), null);
  }
  
  public void info(Object message, Throwable exception)
  {
    log(Level.INFO, String.valueOf(message), exception);
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isLoggable(Level.FINE);
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isLoggable(Level.SEVERE);
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isLoggable(Level.SEVERE);
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isLoggable(Level.INFO);
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isLoggable(Level.FINEST);
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isLoggable(Level.WARNING);
  }
  
  public void trace(Object message)
  {
    log(Level.FINEST, String.valueOf(message), null);
  }
  
  public void trace(Object message, Throwable exception)
  {
    log(Level.FINEST, String.valueOf(message), exception);
  }
  
  public void warn(Object message)
  {
    log(Level.WARNING, String.valueOf(message), null);
  }
  
  public void warn(Object message, Throwable exception)
  {
    log(Level.WARNING, String.valueOf(message), exception);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Jdk14Logger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.Serializable;
import java.lang.reflect.Field;
import org.apache.commons.logging.Log;
import org.apache.log4j.Category;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;

public class Log4JLogger
  implements Log, Serializable
{
  private static final long serialVersionUID = 5160705895411730424L;
  private static final String FQCN = Log4JLogger.class.getName();
  private volatile transient Logger logger = null;
  private final String name;
  private static final Priority traceLevel;
  
  static
  {
    if (!Priority.class.isAssignableFrom(Level.class)) {
      throw new InstantiationError("Log4J 1.2 not available");
    }
    Priority _traceLevel;
    try
    {
      _traceLevel = (Priority)Level.class.getDeclaredField("TRACE").get(null);
    }
    catch (Exception ex)
    {
      _traceLevel = Level.DEBUG;
    }
    traceLevel = _traceLevel;
  }
  
  public Log4JLogger()
  {
    name = null;
  }
  
  public Log4JLogger(String name)
  {
    this.name = name;
    logger = getLogger();
  }
  
  public Log4JLogger(Logger logger)
  {
    if (logger == null) {
      throw new IllegalArgumentException("Warning - null logger in constructor; possible log4j misconfiguration.");
    }
    name = logger.getName();
    this.logger = logger;
  }
  
  public void trace(Object message)
  {
    getLogger().log(FQCN, traceLevel, message, null);
  }
  
  public void trace(Object message, Throwable t)
  {
    getLogger().log(FQCN, traceLevel, message, t);
  }
  
  public void debug(Object message)
  {
    getLogger().log(FQCN, Level.DEBUG, message, null);
  }
  
  public void debug(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.DEBUG, message, t);
  }
  
  public void info(Object message)
  {
    getLogger().log(FQCN, Level.INFO, message, null);
  }
  
  public void info(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.INFO, message, t);
  }
  
  public void warn(Object message)
  {
    getLogger().log(FQCN, Level.WARN, message, null);
  }
  
  public void warn(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.WARN, message, t);
  }
  
  public void error(Object message)
  {
    getLogger().log(FQCN, Level.ERROR, message, null);
  }
  
  public void error(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.ERROR, message, t);
  }
  
  public void fatal(Object message)
  {
    getLogger().log(FQCN, Level.FATAL, message, null);
  }
  
  public void fatal(Object message, Throwable t)
  {
    getLogger().log(FQCN, Level.FATAL, message, t);
  }
  
  public Logger getLogger()
  {
    Logger result = logger;
    if (result == null) {
      synchronized (this)
      {
        result = logger;
        if (result == null) {
          logger = (result = Logger.getLogger(name));
        }
      }
    }
    return result;
  }
  
  public boolean isDebugEnabled()
  {
    return getLogger().isDebugEnabled();
  }
  
  public boolean isErrorEnabled()
  {
    return getLogger().isEnabledFor(Level.ERROR);
  }
  
  public boolean isFatalEnabled()
  {
    return getLogger().isEnabledFor(Level.FATAL);
  }
  
  public boolean isInfoEnabled()
  {
    return getLogger().isInfoEnabled();
  }
  
  public boolean isTraceEnabled()
  {
    return getLogger().isEnabledFor(traceLevel);
  }
  
  public boolean isWarnEnabled()
  {
    return getLogger().isEnabledFor(Level.WARN);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.Log4JLogger
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

final class LogFactoryImpl$1
  implements PrivilegedAction
{
  public Object run()
  {
    return LogFactoryImpl.access$000();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

final class LogFactoryImpl$2
  implements PrivilegedAction
{
  private final String val$key;
  private final String val$def;
  
  LogFactoryImpl$2(String paramString1, String paramString2)
  {
    val$key = paramString1;val$def = paramString2;
  }
  
  public Object run()
  {
    return System.getProperty(val$key, val$def);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl.2
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.security.PrivilegedAction;

class LogFactoryImpl$3
  implements PrivilegedAction
{
  private final ClassLoader val$cl;
  private final LogFactoryImpl this$0;
  
  LogFactoryImpl$3(LogFactoryImpl paramLogFactoryImpl, ClassLoader paramClassLoader)
  {
    this$0 = paramLogFactoryImpl;val$cl = paramClassLoader;
  }
  
  public Object run()
  {
    return val$cl.getParent();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.logging.impl.LogFactoryImpl.3
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.logging.impl;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Hashtable;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory;

public class LogFactoryImpl
  extends LogFactory
{
  private static final String LOGGING_IMPL_LOG4J_LOGGER = "org.apache.commons.logging.impl.Log4JLogger";
  private static final String LOGGING_IMPL_JDK14_LOGGER = "org.apache.commons.logging.impl.Jdk14Logger";
  private static final String LOGGING_IMPL_LUMBERJACK_LOGGER = "org.apache.commons.logging.impl.Jdk13LumberjackLogger";
  private static final String LOGGING_IMPL_SIMPLE_LOGGER = "org.apache.commons.logging.impl.SimpleLog";
  private static final String PKG_IMPL = "org.apache.commons.logging.impl.";
  private static final int PKG_LEN = "org.apache.commons.logging.impl.".length();
  public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
  protected static final String LOG_PROPERTY_OLD = "org.apache.commons.logging.log";
  public static final String ALLOW_FLAWED_CONTEXT_PROPERTY = "org.apache.commons.logging.Log.allowFlawedContext";
  public static final String ALLOW_FLAWED_DISCOVERY_PROPERTY = "org.apache.commons.logging.Log.allowFlawedDiscovery";
  public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY = "org.apache.commons.logging.Log.allowFlawedHierarchy";
  
  public LogFactoryImpl()
  {
    initDiagnostics();
    if (isDiagnosticsEnabled()) {
      logDiagnostic("Instance created.");
    }
  }
  
  private static final String[] classesToDiscover = { "org.apache.commons.logging.impl.Log4JLogger", "org.apache.commons.logging.impl.Jdk14Logger", "org.apache.commons.logging.impl.Jdk13LumberjackLogger", "org.apache.commons.logging.impl.SimpleLog" };
  private boolean useTCCL = true;
  private String diagnosticPrefix;
  protected Hashtable attributes = new Hashtable();
  protected Hashtable instances = new Hashtable();
  private String logClassName;
  protected Constructor logConstructor = null;
  protected Class[] logConstructorSignature = { String.class };
  protected Method logMethod = null;
  protected Class[] logMethodSignature = { LogFactory.class };
  private boolean allowFlawedContext;
  private boolean allowFlawedDiscovery;
  private boolean allowFlawedHierarchy;
  
  public Object getAttribute(String name)
  {
    return attributes.get(name);
  }
  
  public String[] getAttributeNames()
  {
    return (String[])attributes.keySet().toArray(new String[attributes.size()]);
  }
  
  public Log getInstance(Class clazz)
    throws LogConfigurationException
  {
    return getInstance(clazz.getName());
  }
  
  public Log getInstance(String name)
    throws LogConfigurationException
  {
    Log instance = (Log)instances.get(name);
    if (instance == null)
    {
      instance = newInstance(name);
      instances.put(name, instance);
    }
    return instance;
  }
  
  public void release()
  {
    logDiagnostic("Releasing all known loggers");
    instances.clear();
  }
  
  public void removeAttribute(String name)
  {
    attributes.remove(name);
  }
  
  public void setAttribute(String name, Object value)
  {
    if (logConstructor != null) {
      logDiagnostic("setAttribute: call too late; configuration already performed.");
    }
    if (value == null) {
      attributes.remove(name);
    } else {
      attributes.put(name, value);
    }
    if (name.equals("use_tccl")) {
      useTCCL = ((value != null) && (Boolean.valueOf(value.toString()).booleanValue()));
    }
  }
  
  protected static ClassLoader getContextClassLoader()
    throws LogConfigurationException
  {
    return LogFactory.getContextClassLoader();
  }
  
  protected static boolean isDiagnosticsEnabled()
  {
    return LogFactory.isDiagnosticsEnabled();
  }
  
  protected static ClassLoader getClassLoader(Class clazz)
  {
    return LogFactory.getClassLoader(clazz);
  }
  
  private void initDiagnostics()
  {
    Class clazz = getClass();
    ClassLoader classLoader = getClassLoader(clazz);
    String classLoaderName;
    try
    {
      String classLoaderName;
      if (classLoader == null) {
        classLoaderName = "BOOTLOADER";
      } else {
        classLoaderName = LogFactory.objectId(classLoader);
      }
    }
    catch (SecurityException e)
    {
      classLoaderName = "UNKNOWN";
    }
    diagnosticPrefix = ("[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] ");
  }
  
  protected void logDiagnostic(String msg)
  {
    if (isDiagnosticsEnabled()) {
      LogFactory.logRawDiagnostic(diagnosticPrefix + msg);
    }
  }
  
  /**
   * @deprecated
   */
  protected String getLogClassName()
  {
    if (logClassName == null) {
      discoverLogImplementation(getClass().getName());
    }
    return logClassName;
  }
  
  /**
   * @deprecated
   */
  protected Constructor getLogConstructor()
    throws LogConfigurationException
  {
    if (logConstructor == null) {
      discoverLogImplementation(getClass().getName());
    }
    return logConstructor;
  }
  
  /**
   * @deprecated
   */
  protected boolean isJdk13LumberjackAvailable()
  {
    return isLogLibraryAvailable("Jdk13Lumberjack", "org.apache.comm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd