slf4j-log4j12-1.6.4

16:52:53.450 INFO  jd.cli.Main - Decompiling slf4j-log4j12-1.6.4.jar
package org.slf4j.impl;

import java.io.Serializable;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.slf4j.Marker;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MarkerIgnoringBase;
import org.slf4j.helpers.MessageFormatter;
import org.slf4j.spi.LocationAwareLogger;

public final class Log4jLoggerAdapter
  extends MarkerIgnoringBase
  implements LocationAwareLogger, Serializable
{
  private static final long serialVersionUID = 6182834493563598289L;
  final transient Logger logger;
  static final String FQCN = Log4jLoggerAdapter.class.getName();
  final boolean traceCapable;
  
  Log4jLoggerAdapter(Logger logger)
  {
    this.logger = logger;
    name = logger.getName();
    traceCapable = isTraceCapable();
  }
  
  private boolean isTraceCapable()
  {
    try
    {
      logger.isTraceEnabled();
      return true;
    }
    catch (NoSuchMethodError e) {}
    return false;
  }
  
  public boolean isTraceEnabled()
  {
    if (traceCapable) {
      return logger.isTraceEnabled();
    }
    return logger.isDebugEnabled();
  }
  
  public void trace(String msg)
  {
    logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msg, null);
  }
  
  public void trace(String format, Object arg)
  {
    if (isTraceEnabled())
    {
      FormattingTuple ft = MessageFormatter.format(format, arg);
      logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void trace(String format, Object arg1, Object arg2)
  {
    if (isTraceEnabled())
    {
      FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
      logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void trace(String format, Object[] argArray)
  {
    if (isTraceEnabled())
    {
      FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
      logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void trace(String msg, Throwable t)
  {
    logger.log(FQCN, traceCapable ? Level.TRACE : Level.DEBUG, msg, t);
  }
  
  public boolean isDebugEnabled()
  {
    return logger.isDebugEnabled();
  }
  
  public void debug(String msg)
  {
    logger.log(FQCN, Level.DEBUG, msg, null);
  }
  
  public void debug(String format, Object arg)
  {
    if (logger.isDebugEnabled())
    {
      FormattingTuple ft = MessageFormatter.format(format, arg);
      logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void debug(String format, Object arg1, Object arg2)
  {
    if (logger.isDebugEnabled())
    {
      FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
      logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void debug(String format, Object[] argArray)
  {
    if (logger.isDebugEnabled())
    {
      FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
      logger.log(FQCN, Level.DEBUG, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void debug(String msg, Throwable t)
  {
    logger.log(FQCN, Level.DEBUG, msg, t);
  }
  
  public boolean isInfoEnabled()
  {
    return logger.isInfoEnabled();
  }
  
  public void info(String msg)
  {
    logger.log(FQCN, Level.INFO, msg, null);
  }
  
  public void info(String format, Object arg)
  {
    if (logger.isInfoEnabled())
    {
      FormattingTuple ft = MessageFormatter.format(format, arg);
      logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void info(String format, Object arg1, Object arg2)
  {
    if (logger.isInfoEnabled())
    {
      FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
      logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void info(String format, Object[] argArray)
  {
    if (logger.isInfoEnabled())
    {
      FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
      logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void info(String msg, Throwable t)
  {
    logger.log(FQCN, Level.INFO, msg, t);
  }
  
  public boolean isWarnEnabled()
  {
    return logger.isEnabledFor(Level.WARN);
  }
  
  public void warn(String msg)
  {
    logger.log(FQCN, Level.WARN, msg, null);
  }
  
  public void warn(String format, Object arg)
  {
    if (logger.isEnabledFor(Level.WARN))
    {
      FormattingTuple ft = MessageFormatter.format(format, arg);
      logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void warn(String format, Object arg1, Object arg2)
  {
    if (logger.isEnabledFor(Level.WARN))
    {
      FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
      logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void warn(String format, Object[] argArray)
  {
    if (logger.isEnabledFor(Level.WARN))
    {
      FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
      logger.log(FQCN, Level.WARN, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void warn(String msg, Throwable t)
  {
    logger.log(FQCN, Level.WARN, msg, t);
  }
  
  public boolean isErrorEnabled()
  {
    return logger.isEnabledFor(Level.ERROR);
  }
  
  public void error(String msg)
  {
    logger.log(FQCN, Level.ERROR, msg, null);
  }
  
  public void error(String format, Object arg)
  {
    if (logger.isEnabledFor(Level.ERROR))
    {
      FormattingTuple ft = MessageFormatter.format(format, arg);
      logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void error(String format, Object arg1, Object arg2)
  {
    if (logger.isEnabledFor(Level.ERROR))
    {
      FormattingTuple ft = MessageFormatter.format(format, arg1, arg2);
      logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void error(String format, Object[] argArray)
  {
    if (logger.isEnabledFor(Level.ERROR))
    {
      FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
      logger.log(FQCN, Level.ERROR, ft.getMessage(), ft.getThrowable());
    }
  }
  
  public void error(String msg, Throwable t)
  {
    logger.log(FQCN, Level.ERROR, msg, t);
  }
  
  public void log(Marker marker, String callerFQCN, int level, String msg, Object[] argArray, Throwable t)
  {
    Level log4jLevel;
    switch (level)
    {
    case 0: 
      log4jLevel = traceCapable ? Level.TRACE : Level.DEBUG;
      break;
    case 10: 
      log4jLevel = Level.DEBUG;
      break;
    case 20: 
      log4jLevel = Level.INFO;
      break;
    case 30: 
      log4jLevel = Level.WARN;
      break;
    case 40: 
      log4jLevel = Level.ERROR;
      break;
    default: 
      throw new IllegalStateException("Level number " + level + " is not recognized.");
    }
    logger.log(callerFQCN, log4jLevel, msg, t);
  }
}

/* Location:
 * Qualified Name:     org.slf4j.impl.Log4jLoggerAdapter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.slf4j.impl;

import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.LogManager;
import org.slf4j.ILoggerFactory;

public class Log4jLoggerFactory
  implements ILoggerFactory
{
  Map loggerMap;
  
  public Log4jLoggerFactory()
  {
    loggerMap = new HashMap();
  }
  
  public org.slf4j.Logger getLogger(String name)
  {
    org.slf4j.Logger slf4jLogger = null;
    synchronized (this)
    {
      slf4jLogger = (org.slf4j.Logger)loggerMap.get(name);
      if (slf4jLogger == null)
      {
        org.apache.log4j.Logger log4jLogger;
        org.apache.log4j.Logger log4jLogger;
        if (name.equalsIgnoreCase("ROOT")) {
          log4jLogger = LogManager.getRootLogger();
        } else {
          log4jLogger = LogManager.getLogger(name);
        }
        slf4jLogger = new Log4jLoggerAdapter(log4jLogger);
        loggerMap.put(name, slf4jLogger);
      }
    }
    return slf4jLogger;
  }
}

/* Location:
 * Qualified Name:     org.slf4j.impl.Log4jLoggerFactory
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.slf4j.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.log4j.MDC;
import org.slf4j.spi.MDCAdapter;

public class Log4jMDCAdapter
  implements MDCAdapter
{
  public void clear()
  {
    Map map = MDC.getContext();
    if (map != null) {
      map.clear();
    }
  }
  
  public String get(String key)
  {
    return (String)MDC.get(key);
  }
  
  public void put(String key, String val)
  {
    MDC.put(key, val);
  }
  
  public void remove(String key)
  {
    MDC.remove(key);
  }
  
  public Map getCopyOfContextMap()
  {
    Map old = MDC.getContext();
    if (old != null) {
      return new HashMap(old);
    }
    return null;
  }
  
  public void setContextMap(Map contextMap)
  {
    Map old = MDC.getContext();
    if (old == null)
    {
      Iterator entrySetIterator = contextMap.entrySet().iterator();
      while (entrySetIterator.hasNext())
      {
        Map.Entry mapEntry = (Map.Entry)entrySetIterator.next();
        MDC.put((String)mapEntry.getKey(), mapEntry.getValue());
      }
    }
    else
    {
      old.clear();
      old.putAll(contextMap);
    }
  }
}

/* Location:
 * Qualified Name:     org.slf4j.impl.Log4jMDCAdapter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.slf4j.impl;

import org.apache.log4j.Level;
import org.slf4j.ILoggerFactory;
import org.slf4j.helpers.Util;
import org.slf4j.spi.LoggerFactoryBinder;

public class StaticLoggerBinder
  implements LoggerFactoryBinder
{
  private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
  
  public static final StaticLoggerBinder getSingleton()
  {
    return SINGLETON;
  }
  
  public static String REQUESTED_API_VERSION = "1.6";
  private static final String loggerFactoryClassStr = Log4jLoggerFactory.class.getName();
  private final ILoggerFactory loggerFactory;
  
  private StaticLoggerBinder()
  {
    loggerFactory = new Log4jLoggerFactory();
    try
    {
      level = Level.TRACE;
    }
    catch (NoSuchFieldError nsfe)
    {
      Level level;
      Util.report("This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version");
    }
  }
  
  public ILoggerFactory getLoggerFactory()
  {
    return loggerFactory;
  }
  
  public String getLoggerFactoryClassStr()
  {
    return loggerFactoryClassStr;
  }
}

/* Location:
 * Qualified Name:     org.slf4j.impl.StaticLoggerBinder
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.slf4j.impl;

import org.slf4j.IMarkerFactory;
import org.slf4j.helpers.BasicMarkerFactory;
import org.slf4j.spi.MarkerFactoryBinder;

public class StaticMarkerBinder
  implements MarkerFactoryBinder
{
  public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
  final IMarkerFactory markerFactory = new BasicMarkerFactory();
  
  public IMarkerFactory getMarkerFactory()
  {
    return markerFactory;
  }
  
  public String getMarkerFactoryClassStr()
  {
    return BasicMarkerFactory.class.getName();
  }
}

/* Location:
 * Qualified Name:     org.slf4j.impl.StaticMarkerBinder
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.slf4j.impl;

import org.slf4j.spi.MDCAdapter;

public class StaticMDCBinder
{
  public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
  
  public MDCAdapter getMDCA()
  {
    return new Log4jMDCAdapter();
  }
  
  public String getMDCAdapterClassStr()
  {
    return Log4jMDCAdapter.class.getName();
  }
}

/* Location:
 * Qualified Name:     org.slf4j.impl.StaticMDCBinder
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
1

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-2017. Infinite Loop Ltd