logback-classic-0.9.9

16:38:56.790 INFO  jd.cli.Main - Decompiling logback-classic-0.9.9.jar
package ch.qos.logback.classic;

import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.ConsoleAppender;
import ch.qos.logback.core.status.InfoStatus;
import ch.qos.logback.core.status.StatusManager;
import org.slf4j.LoggerFactory;

public class BasicConfigurator
{
  static final BasicConfigurator hiddenSingleton = new BasicConfigurator();
  
  public static void configure(LoggerContext lc)
  {
    StatusManager sm = lc.getStatusManager();
    if (sm != null) {
      sm.add(new InfoStatus("Setting up default configuration.", hiddenSingleton));
    }
    ConsoleAppender<LoggingEvent> ca = new ConsoleAppender();
    ca.setContext(lc);
    ca.setName("console");
    PatternLayout pl = new PatternLayout();
    pl.setContext(lc);
    pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
    pl.start();
    
    ca.setLayout(pl);
    ca.start();
    Logger rootLogger = lc.getLogger("root");
    rootLogger.addAppender(ca);
  }
  
  public static void configureDefaultContext()
  {
    LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
    configure(lc);
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.BasicConfigurator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.boolex;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.ThrowableInformation;
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
import ch.qos.logback.core.boolex.Matcher;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Marker;

public class JaninoEventEvaluator
  extends JaninoEventEvaluatorBase
{
  public static final String IMPORT_LEVEL = "import ch.qos.logback.classic.Level;\r\n";
  public static final List<String> DEFAULT_PARAM_NAME_LIST = new ArrayList();
  public static final List<Class> DEFAULT_PARAM_TYPE_LIST = new ArrayList();
  
  static
  {
    DEFAULT_PARAM_NAME_LIST.add("DEBUG");
    DEFAULT_PARAM_NAME_LIST.add("INFO");
    DEFAULT_PARAM_NAME_LIST.add("WARN");
    DEFAULT_PARAM_NAME_LIST.add("ERROR");
    
    DEFAULT_PARAM_NAME_LIST.add("event");
    DEFAULT_PARAM_NAME_LIST.add("message");
    DEFAULT_PARAM_NAME_LIST.add("logger");
    DEFAULT_PARAM_NAME_LIST.add("level");
    DEFAULT_PARAM_NAME_LIST.add("timeStamp");
    DEFAULT_PARAM_NAME_LIST.add("marker");
    DEFAULT_PARAM_NAME_LIST.add("mdc");
    DEFAULT_PARAM_NAME_LIST.add("throwable");
    
    DEFAULT_PARAM_TYPE_LIST.add(Integer.TYPE);
    DEFAULT_PARAM_TYPE_LIST.add(Integer.TYPE);
    DEFAULT_PARAM_TYPE_LIST.add(Integer.TYPE);
    DEFAULT_PARAM_TYPE_LIST.add(Integer.TYPE);
    
    DEFAULT_PARAM_TYPE_LIST.add(LoggingEvent.class);
    DEFAULT_PARAM_TYPE_LIST.add(String.class);
    DEFAULT_PARAM_TYPE_LIST.add(LoggerRemoteView.class);
    DEFAULT_PARAM_TYPE_LIST.add(Integer.TYPE);
    DEFAULT_PARAM_TYPE_LIST.add(Long.TYPE);
    DEFAULT_PARAM_TYPE_LIST.add(Marker.class);
    DEFAULT_PARAM_TYPE_LIST.add(Map.class);
    DEFAULT_PARAM_TYPE_LIST.add(Throwable.class);
  }
  
  protected String getDecoratedExpression()
  {
    return "import ch.qos.logback.classic.Level;\r\n" + getExpression();
  }
  
  protected String[] getParameterNames()
  {
    List<String> fullNameList = new ArrayList();
    fullNameList.addAll(DEFAULT_PARAM_NAME_LIST);
    for (int i = 0; i < matcherList.size(); i++)
    {
      Matcher m = (Matcher)matcherList.get(i);
      fullNameList.add(m.getName());
    }
    return (String[])fullNameList.toArray(CoreGlobal.EMPTY_STRING_ARRAY);
  }
  
  protected Class[] getParameterTypes()
  {
    List<Class> fullTypeList = new ArrayList();
    fullTypeList.addAll(DEFAULT_PARAM_TYPE_LIST);
    for (int i = 0; i < matcherList.size(); i++) {
      fullTypeList.add(Matcher.class);
    }
    return (Class[])fullTypeList.toArray(CoreGlobal.EMPTY_CLASS_ARRAY);
  }
  
  protected Object[] getParameterValues(Object event)
  {
    LoggingEvent loggingEvent = (LoggingEvent)event;
    int matcherListSize = matcherList.size();
    
    int i = 0;
    Object[] values = new Object[DEFAULT_PARAM_NAME_LIST.size() + matcherListSize];
    
    values[(i++)] = Level.DEBUG_INTEGER;
    values[(i++)] = Level.INFO_INTEGER;
    values[(i++)] = Level.WARN_INTEGER;
    values[(i++)] = Level.ERROR_INTEGER;
    
    values[(i++)] = loggingEvent;
    values[(i++)] = loggingEvent.getMessage();
    values[(i++)] = loggingEvent.getLoggerRemoteView();
    values[(i++)] = loggingEvent.getLevel().toInteger();
    values[(i++)] = new Long(loggingEvent.getTimeStamp());
    values[(i++)] = loggingEvent.getMarker();
    values[(i++)] = loggingEvent.getMDCPropertyMap();
    if (loggingEvent.getThrowableInformation() != null) {
      values[(i++)] = loggingEvent.getThrowableInformation().getThrowable();
    } else {
      values[(i++)] = null;
    }
    for (int j = 0; j < matcherListSize; j++) {
      values[(i++)] = ((Matcher)matcherList.get(j));
    }
    return values;
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.boolex.JaninoEventEvaluator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic;

public class ClassicGlobal
{
  public static final char LOGGER_SEPARATOR = '.';
  public static final String CAUSED_BY = "Caused by: ";
  public static final char DOT = '.';
  public static final String USER_MDC_KEY = "user";
  public static final String LOGBACK_CONTEXT_SELECTOR = "logback.ContextSelector";
  public static String JNDI_CONFIGURATION_RESOURCE = "java:comp/env/logback/configuration-resource";
  public static String JNDI_CONTEXT_NAME = "java:comp/env/logback/context-name";
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.ClassicGlobal
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.db;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.CallerData;
import ch.qos.logback.classic.spi.LoggerContextRemoteView;
import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.ThrowableInformation;
import ch.qos.logback.core.db.DBAppenderBase;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class DBAppender
  extends DBAppenderBase<LoggingEvent>
{
  protected final String insertPropertiesSQL = "INSERT INTO  logging_event_property (event_id, mapped_key, mapped_value) VALUES (?, ?, ?)";
  protected final String insertExceptionSQL = "INSERT INTO  logging_event_exception (event_id, i, trace_line) VALUES (?, ?, ?)";
  protected static final String insertSQL;
  protected static final Method GET_GENERATED_KEYS_METHOD;
  
  static
  {
    StringBuffer sql = new StringBuffer();
    sql.append("INSERT INTO logging_event (");
    sql.append("timestmp, ");
    sql.append("formatted_message, ");
    sql.append("logger_name, ");
    sql.append("level_string, ");
    sql.append("thread_name, ");
    sql.append("reference_flag, ");
    sql.append("caller_filename, ");
    sql.append("caller_class, ");
    sql.append("caller_method, ");
    sql.append("caller_line) ");
    sql.append(" VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?,?)");
    insertSQL = sql.toString();
    Method getGeneratedKeysMethod;
    try
    {
      getGeneratedKeysMethod = PreparedStatement.class.getMethod("getGeneratedKeys", (Class[])null);
    }
    catch (Exception ex)
    {
      getGeneratedKeysMethod = null;
    }
    GET_GENERATED_KEYS_METHOD = getGeneratedKeysMethod;
  }
  
  protected void subAppend(Object eventObject, Connection connection, PreparedStatement insertStatement)
    throws Throwable
  {
    LoggingEvent event = (LoggingEvent)eventObject;
    
    addLoggingEvent(insertStatement, event);
    
    addCallerData(insertStatement, event.getCallerData());
    
    int updateCount = insertStatement.executeUpdate();
    if (updateCount != 1) {
      addWarn("Failed to insert loggingEvent");
    }
    int eventId = getEventId(insertStatement, connection);
    
    Map<String, String> mergedMap = mergePropertyMaps(event);
    insertProperties(mergedMap, connection, eventId);
    if (event.getThrowableInformation() != null) {
      insertThrowable(event.getThrowableInformation().getThrowableStrRep(), connection, eventId);
    }
  }
  
  void addLoggingEvent(PreparedStatement stmt, LoggingEvent event)
    throws SQLException
  {
    stmt.setLong(1, event.getTimeStamp());
    stmt.setString(2, event.getFormattedMessage());
    stmt.setString(3, event.getLoggerRemoteView().getName());
    stmt.setString(4, event.getLevel().toString());
    stmt.setString(5, event.getThreadName());
    stmt.setShort(6, DBHelper.computeReferenceMask(event));
  }
  
  void addCallerData(PreparedStatement stmt, CallerData[] callerDataArray)
    throws SQLException
  {
    CallerData callerData = callerDataArray[0];
    if (callerData != null)
    {
      stmt.setString(7, callerData.getFileName());
      stmt.setString(8, callerData.getClassName());
      stmt.setString(9, callerData.getMethodName());
      stmt.setString(10, Integer.toString(callerData.getLineNumber()));
    }
  }
  
  Map<String, String> mergePropertyMaps(LoggingEvent event)
  {
    Map<String, String> mergedMap = new HashMap();
    
    Map<String, String> loggerContextMap = event.getLoggerRemoteView().getLoggerContextView().getPropertyMap();
    
    Map<String, String> mdcMap = event.getMDCPropertyMap();
    if (loggerContextMap != null) {
      mergedMap.putAll(loggerContextMap);
    }
    if (mdcMap != null) {
      mergedMap.putAll(mdcMap);
    }
    return mergedMap;
  }
  
  protected Method getGeneratedKeysMethod()
  {
    return GET_GENERATED_KEYS_METHOD;
  }
  
  protected String getInsertSQL()
  {
    return insertSQL;
  }
  
  protected void insertProperties(Map<String, String> mergedMap, Connection connection, int eventId)
    throws SQLException
  {
    Set propertiesKeys = mergedMap.keySet();
    if (propertiesKeys.size() > 0)
    {
      PreparedStatement insertPropertiesStatement = connection.prepareStatement("INSERT INTO  logging_event_property (event_id, mapped_key, mapped_value) VALUES (?, ?, ?)");
      for (Iterator i = propertiesKeys.iterator(); i.hasNext();)
      {
        String key = (String)i.next();
        String value = (String)mergedMap.get(key);
        
        insertPropertiesStatement.setInt(1, eventId);
        insertPropertiesStatement.setString(2, key);
        insertPropertiesStatement.setString(3, value);
        if (cnxSupportsBatchUpdates) {
          insertPropertiesStatement.addBatch();
        } else {
          insertPropertiesStatement.execute();
        }
      }
      if (cnxSupportsBatchUpdates) {
        insertPropertiesStatement.executeBatch();
      }
      insertPropertiesStatement.close();
      insertPropertiesStatement = null;
    }
  }
  
  protected void insertThrowable(String[] strRep, Connection connection, int eventId)
    throws SQLException
  {
    PreparedStatement insertExceptionStatement = connection.prepareStatement("INSERT INTO  logging_event_exception (event_id, i, trace_line) VALUES (?, ?, ?)");
    for (short i = 0; i < strRep.length; i = (short)(i + 1))
    {
      insertExceptionStatement.setInt(1, eventId);
      insertExceptionStatement.setShort(2, i);
      insertExceptionStatement.setString(3, strRep[i]);
      if (cnxSupportsBatchUpdates) {
        insertExceptionStatement.addBatch();
      } else {
        insertExceptionStatement.execute();
      }
    }
    if (cnxSupportsBatchUpdates) {
      insertExceptionStatement.executeBatch();
    }
    insertExceptionStatement.close();
    insertExceptionStatement = null;
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.db.DBAppender
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.db;

import ch.qos.logback.classic.spi.LoggerContextRemoteView;
import ch.qos.logback.classic.spi.LoggerRemoteView;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.ThrowableInformation;
import java.util.Map;
import java.util.Set;

public class DBHelper
{
  public static short PROPERTIES_EXIST = 1;
  public static short EXCEPTION_EXISTS = 2;
  
  public static short computeReferenceMask(LoggingEvent event)
  {
    short mask = 0;
    
    int mdcPropSize = 0;
    if (event.getMDCPropertyMap() != null) {
      mdcPropSize = event.getMDCPropertyMap().keySet().size();
    }
    int contextPropSize = 0;
    if (event.getLoggerRemoteView().getLoggerContextView().getPropertyMap() != null) {
      contextPropSize = event.getLoggerRemoteView().getLoggerContextView().getPropertyMap().size();
    }
    if ((mdcPropSize > 0) || (contextPropSize > 0)) {
      mask = PROPERTIES_EXIST;
    }
    if (event.getThrowableInformation() != null)
    {
      String[] strRep = event.getThrowableInformation().getThrowableStrRep();
      if (strRep != null) {
        mask = (short)(mask | EXCEPTION_EXISTS);
      }
    }
    return mask;
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.db.DBHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.filter;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.filter.AbstractMatcherFilter;
import ch.qos.logback.core.spi.FilterReply;

public class LevelFilter
  extends AbstractMatcherFilter
{
  Level level;
  
  public FilterReply decide(Object eventObject)
  {
    if (!isStarted()) {
      return FilterReply.NEUTRAL;
    }
    LoggingEvent event = (LoggingEvent)eventObject;
    if (event.getLevel().equals(level)) {
      return onMatch;
    }
    return onMismatch;
  }
  
  public void setLevel(String level)
  {
    this.level = Level.toLevel(level);
  }
  
  public void start()
  {
    if (level != null) {
      super.start();
    }
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.filter.LevelFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.filter;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

public class ThresholdFilter
  extends Filter
{
  Level level;
  
  public FilterReply decide(Object eventObject)
  {
    if (!isStarted()) {
      return FilterReply.NEUTRAL;
    }
    LoggingEvent event = (LoggingEvent)eventObject;
    if (event.getLevel().isGreaterOrEqual(level)) {
      return FilterReply.NEUTRAL;
    }
    return FilterReply.DENY;
  }
  
  public void setLevel(String level)
  {
    this.level = Level.toLevel(level);
  }
  
  public void start()
  {
    if (level != null) {
      super.start();
    }
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.filter.ThresholdFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.helpers;

public class PlatformInfo
{
  private static final int UNINITIALIZED = -1;
  private static int hasJMXObjectName = -1;
  
  public static boolean hasJMXObjectName()
  {
    if (hasJMXObjectName == -1) {
      try
      {
        Class.forName("javax.management.ObjectName");
        hasJMXObjectName = 1;
      }
      catch (Throwable e)
      {
        hasJMXObjectName = 0;
      }
    }
    return hasJMXObjectName == 1;
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.helpers.PlatformInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.helpers;

public class Transform
{
  private static final String CDATA_START = "<![CDATA[";
  private static final String CDATA_END = "]]>";
  private static final String CDATA_PSEUDO_END = "]]&gt;";
  private static final String CDATA_EMBEDED_END = "]]>]]&gt;<![CDATA[";
  private static final int CDATA_END_LEN = "]]>".length();
  
  public static String escapeTags(String input)
  {
    if ((input == null) || (input.length() == 0) || ((input.indexOf("<") == -1) && (input.indexOf(">") == -1))) {
      return input;
    }
    StringBuffer buf = new StringBuffer(input);
    for (int i = 0; i < buf.length(); i++)
    {
      char ch = buf.charAt(i);
      if (ch == '<') {
        buf.replace(i, i + 1, "&lt;");
      } else if (ch == '>') {
        buf.replace(i, i + 1, "&gt;");
      }
    }
    return buf.toString();
  }
  
  public static void appendEscapingCDATA(StringBuffer output, String str)
  {
    if (str == null) {
      return;
    }
    int end = str.indexOf("]]>");
    if (end < 0)
    {
      output.append(str);
      
      return;
    }
    int start = 0;
    while (end > -1)
    {
      output.append(str.substring(start, end));
      output.append("]]>]]&gt;<![CDATA[");
      start = end + CDATA_END_LEN;
      if (start < str.length()) {
        end = str.indexOf("]]>", start);
      } else {
        return;
      }
    }
    output.append(str.substring(start));
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.helpers.Transform
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.html;

import ch.qos.logback.core.Layout;
import ch.qos.logback.core.html.CssBuilder;

public class DefaultCssBuilder
  implements CssBuilder
{
  public void addCss(StringBuffer sbuf)
  {
    sbuf.append("<STYLE  type=\"text/css\">");
    sbuf.append(Layout.LINE_SEP);
    sbuf.append("table { margin-left: 2em; margin-right: 2em; border-left: 2px solid #AAA; }");
    
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TR.even { background: #FFFFFF; }");
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TR.odd { background: #EAEAEA; }");
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TR.warn TD.Level, TR.error TD.Level, TR.fatal TD.Level {font-weight: bold; color: #FF4040 }");
    
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TD { padding-right: 1ex; padding-left: 1ex; border-right: 2px solid #AAA; }");
    
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TD.Time, TD.Date { text-align: right; font-family: courier, monospace; font-size: smaller; }");
    
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TD.Thread { text-align: left; }");
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TD.Level { text-align: right; }");
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TD.Logger { text-align: left; }");
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TR.header { background: #596ED5; color: #FFF; font-weight: bold; font-size: larger; }");
    
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("TD.Exception { background: #A2AEE8; font-family: courier, monospace;}");
    
    sbuf.append(Layout.LINE_SEP);
    
    sbuf.append("</STYLE>");
    sbuf.append(Layout.LINE_SEP);
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.html.DefaultCssBuilder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.html;

import ch.qos.logback.classic.helpers.Transform;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.ThrowableInformation;
import ch.qos.logback.core.Layout;
import ch.qos.logback.core.html.IThrowableRenderer;

public class DefaultThrowableRenderer
  implements IThrowableRenderer
{
  static final String TRACE_PREFIX = "<br />&nbsp;&nbsp;&nbsp;&nbsp;";
  Throwable throwable;
  
  public void setThrowable(Throwable t)
  {
    throwable = t;
  }
  
  public void render(StringBuffer sbuf, String[] s)
  {
    if (s != null)
    {
      int len = s.length;
      if (len == 0) {
        return;
      }
      sbuf.append("<tr><td class=\"Exception\" colspan=\"6\">");
      sbuf.append(Transform.escapeTags(s[0]));
      sbuf.append(Layout.LINE_SEP);
      for (int i = 1; i < len; i++)
      {
        sbuf.append("<br />&nbsp;&nbsp;&nbsp;&nbsp;");
        sbuf.append(Transform.escapeTags(s[i]));
        sbuf.append(Layout.LINE_SEP);
      }
      sbuf.append("</td></tr>");
    }
  }
  
  public void render(StringBuffer sbuf, Object eventObject)
  {
    LoggingEvent event = (LoggingEvent)eventObject;
    ThrowableInformation ti = event.getThrowableInformation();
    if (ti != null) {
      render(sbuf, ti.getThrowableStrRep());
    }
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.html.DefaultThrowableRenderer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.html;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.html.HTMLLayoutBase;
import ch.qos.logback.core.html.IThrowableRenderer;
import ch.qos.logback.core.pattern.Converter;
import java.util.Map;

public class HTMLLayout
  extends HTMLLayoutBase<LoggingEvent>
{
  static final String DEFAULT_CONVERSION_PATTERN = "%date%thread%level%logger%mdc%msg";
  
  public HTMLLayout()
  {
    pattern = "%date%thread%level%logger%mdc%msg";
    throwableRenderer = new DefaultThrowableRenderer();
    cssBuilder = new DefaultCssBuilder();
  }
  
  protected Map<String, String> getDefaultConverterMap()
  {
    return PatternLayout.defaultConverterMap;
  }
  
  public String doLayout(LoggingEvent event)
  {
    StringBuffer buf = new StringBuffer();
    handleTableClosing(buf);
    
    boolean odd = true;
    if ((counter++ & 1L) == 0L) {
      odd = false;
    }
    String level = event.getLevel().toString().toLowerCase();
    
    buf.append(LINE_SEP);
    buf.append("<tr class=\"");
    buf.append(level);
    if (odd) {
      buf.append(" odd\">");
    } else {
      buf.append(" even\">");
    }
    buf.append(LINE_SEP);
    
    Converter<LoggingEvent> c = head;
    while (c != null)
    {
      appendEventToBuffer(buf, c, event);
      c = c.getNext();
    }
    buf.append("</tr>");
    buf.append(LINE_SEP);
    if (event.getThrowableInformation() != null) {
      throwableRenderer.render(buf, event);
    }
    return buf.toString();
  }
  
  private void appendEventToBuffer(StringBuffer buf, Converter<LoggingEvent> c, LoggingEvent event)
  {
    buf.append("<td class=\"");
    buf.append(computeConverterName(c));
    buf.append("\">");
    buf.append(c.convert(event));
    buf.append("</td>");
    buf.append(LINE_SEP);
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.html.HTMLLayout
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.html;

import ch.qos.logback.core.html.CssBuilder;

public class UrlCssBuilder
  implements CssBuilder
{
  String url = "http://logback.qos.ch/css/classic.css";
  
  public String getUrl()
  {
    return url;
  }
  
  public void setUrl(String url)
  {
    this.url = url;
  }
  
  public void addCss(StringBuffer sbuf)
  {
    sbuf.append("<LINK REL=StyleSheet HREF=\"");
    sbuf.append(url);
    sbuf.append("\" TITLE=\"Basic\" />");
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.html.UrlCssBuilder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.jmx;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.util.ContextInitializer;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusManager;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Configurator
  extends ContextAwareBase
  implements ConfiguratorMBean
{
  private static String EMPTY = "";
  
  public Configurator(LoggerContext loggerContext)
  {
    context = loggerContext;
  }
  
  public void reload()
  {
    LoggerContext lc = (LoggerContext)context;
    addInfo("Shutting down context: " + lc.getName());
    lc.shutdownAndReset();
    try
    {
      ContextInitializer.autoConfig(lc, lc.getClass().getClassLoader());
      addInfo("Context: " + lc.getName() + " reloaded.");
    }
    catch (JoranException je)
    {
      addError("Reloading of context: " + lc.getName() + " failed.", je);
    }
  }
  
  public void reload(String fileName)
    throws JoranException
  {
    LoggerContext lc = (LoggerContext)context;
    addInfo("Shutting down context: " + lc.getName());
    lc.shutdownAndReset();
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(lc);
    configurator.doConfigure(fileName);
    addInfo("Context: " + lc.getName() + " reloaded.");
  }
  
  public void reload(URL url)
    throws JoranException
  {
    LoggerContext lc = (LoggerContext)context;
    addInfo("Shutting down context: " + lc.getName());
    lc.shutdownAndReset();
    ContextInitializer.configureByResource(lc, url);
    addInfo("Context: " + lc.getName() + " reloaded.");
  }
  
  public void setLoggerLevel(String loggerName, String levelStr)
  {
    if (loggerName == null) {
      return;
    }
    if (levelStr == null) {
      return;
    }
    loggerName = loggerName.trim();
    levelStr = levelStr.trim();
    
    addInfo("Trying to set level " + levelStr + " to logger " + loggerName);
    LoggerContext lc = (LoggerContext)context;
    
    Logger logger = lc.getLogger(loggerName);
    if ("null".equalsIgnoreCase(levelStr))
    {
      logger.setLevel(null);
    }
    else
    {
      Level level = Level.toLevel(levelStr, null);
      if (level != null) {
        logger.setLevel(level);
      }
    }
  }
  
  public String getLoggerLevel(String loggerName)
  {
    if (loggerName == null) {
      return EMPTY;
    }
    loggerName = loggerName.trim();
    
    LoggerContext lc = (LoggerContext)context;
    Logger logger = lc.exists(loggerName);
    if (logger != null) {
      return logger.getLevel().toString();
    }
    return EMPTY;
  }
  
  public String getLoggerEffectiveLevel(String loggerName)
  {
    if (loggerName == null) {
      return EMPTY;
    }
    loggerName = loggerName.trim();
    
    LoggerContext lc = (LoggerContext)context;
    Logger logger = lc.exists(loggerName);
    if (logger != null) {
      return logger.getEffectiveLevel().toString();
    }
    return EMPTY;
  }
  
  public List<String> getLoggerList()
  {
    LoggerContext lc = (LoggerContext)context;
    List<String> strList = new ArrayList();
    Iterator<Logger> it = lc.getLoggerList().iterator();
    while (it.hasNext())
    {
      Logger log = (Logger)it.next();
      strList.add(log.getName());
    }
    return strList;
  }
  
  public List<String> getStatuses()
  {
    List<String> list = new ArrayList();
    Iterator<Status> it = context.getStatusManager().iterator();
    while (it.hasNext()) {
      list.add(((Status)it.next()).toString());
    }
    return list;
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.jmx.Configurator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.jmx;

import ch.qos.logback.core.joran.spi.JoranException;
import java.net.URL;
import java.util.List;

public abstract interface ConfiguratorMBean
{
  public abstract void reload();
  
  public abstract void reload(String paramString)
    throws JoranException;
  
  public abstract void reload(URL paramURL)
    throws JoranException;
  
  public abstract void setLoggerLevel(String paramString1, String paramString2);
  
  public abstract String getLoggerLevel(String paramString);
  
  public abstract String getLoggerEffectiveLevel(String paramString);
  
  public abstract List<String> getLoggerList();
  
  public abstract List<String> getStatuses();
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.jmx.ConfiguratorMBean
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.StatusPrinter;
import org.xml.sax.Attributes;

public class ConfigurationAction
  extends Action
{
  static final String INTERNAL_DEBUG_ATTR = "debug";
  boolean debugMode = false;
  
  public void begin(InterpretationContext ec, String name, Attributes attributes)
  {
    String debugAttrib = attributes.getValue("debug");
    if ((debugAttrib == null) || (debugAttrib.equals("")) || (debugAttrib.equals("false")) || (debugAttrib.equals("null"))) {
      addInfo("Ignoring debug attribute.");
    } else {
      debugMode = true;
    }
    ec.pushObject(getContext());
  }
  
  public void end(InterpretationContext ec, String name)
  {
    if (debugMode)
    {
      addInfo("End of configuration.");
      LoggerContext loggerContext = (LoggerContext)context;
      StatusPrinter.print(loggerContext);
    }
    ec.popObject();
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.ConfigurationAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.net.SocketAppender;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.ActionException;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import org.xml.sax.Attributes;

public class ConsolePluginAction
  extends Action
{
  private static final String PORT_ATTR = "port";
  private static final Integer DEFAULT_PORT = Integer.valueOf(4321);
  
  public void begin(InterpretationContext ec, String name, Attributes attributes)
    throws ActionException
  {
    String portStr = attributes.getValue("port");
    Integer port = null;
    if (portStr == null) {
      port = DEFAULT_PORT;
    } else {
      try
      {
        port = Integer.valueOf(portStr);
      }
      catch (NumberFormatException ex)
      {
        addError("Port " + portStr + " in ConsolePlugin config is not a correct number");
      }
    }
    LoggerContext lc = (LoggerContext)ec.getContext();
    SocketAppender appender = new SocketAppender();
    appender.setContext(lc);
    appender.setIncludeCallerData(true);
    appender.setRemoteHost("localhost");
    appender.setPort(port.intValue());
    appender.start();
    Logger root = lc.getLogger("root");
    root.addAppender(appender);
    
    addInfo("Sending LoggingEvents to the plugin using port " + port);
  }
  
  public void end(InterpretationContext ec, String name)
    throws ActionException
  {}
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.ConsolePluginAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
import ch.qos.logback.core.boolex.EventEvaluator;
import ch.qos.logback.core.joran.action.AbstractEventEvaluatorAction;

public class EvaluatorAction
  extends AbstractEventEvaluatorAction
{
  protected boolean isOfCorrectType(EventEvaluator ee)
  {
    return ee instanceof JaninoEventEvaluator;
  }
  
  protected String defaultClassName()
  {
    return JaninoEventEvaluator.class.getName();
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.EvaluatorAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.jmx.Configurator;
import ch.qos.logback.classic.jmx.ConfiguratorMBean;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.ActionException;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.xml.sax.Attributes;

public class JMXConfiguratorAction
  extends Action
{
  static final String DOMAIN = "ch.qos.logback.classic";
  
  public void begin(InterpretationContext ec, String name, Attributes attributes)
    throws ActionException
  {
    register();
  }
  
  public void end(InterpretationContext ec, String name)
    throws ActionException
  {}
  
  public void register()
  {
    ConfiguratorMBean configuratorMBean = new Configurator((LoggerContext)context);
    
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try
    {
      ObjectName on = new ObjectName("ch.qos.logback.classic:Name=" + context.getName() + ",Type=" + configuratorMBean.getClass().getName());
      if (mbs.isRegistered(on)) {
        mbs.unregisterMBean(on);
      }
      mbs.registerMBean(configuratorMBean, on);
    }
    catch (Exception e)
    {
      addError("Failed to create mbean", e);
    }
  }
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.JMXConfiguratorAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.joran.action.AbstractLayoutAction;

public class LayoutAction
  extends AbstractLayoutAction<LoggingEvent>
{}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.LayoutAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import org.xml.sax.Attributes;

public class LevelAction
  extends Action
{
  static final String VALUE_ATTR = "value";
  static final String CLASS_ATTR = "class";
  static final String INHERITED = "INHERITED";
  static final String NULL = "NULL";
  static final String EMPTY_STR = "";
  static final Class[] ONE_STRING_PARAM = { String.class };
  boolean inError = false;
  
  public void begin(InterpretationContext ec, String name, Attributes attributes)
  {
    Object o = ec.peekObject();
    if (!(o instanceof Logger))
    {
      inError = true;
      addError("For element <level>, could not find a logger at the top of execution stack.");
      return;
    }
    Logger l = (Logger)o;
    
    String loggerName = l.getName();
    
    String levelStr = attributes.getValue("value");
    if (("INHERITED".equalsIgnoreCase(levelStr)) || ("NULL".equalsIgnoreCase(levelStr))) {
      l.setLevel(null);
    } else {
      l.setLevel(Level.toLevel(levelStr, Level.DEBUG));
    }
    addInfo(loggerName + " level set to " + l.getLevel());
  }
  
  public void finish(InterpretationContext ec) {}
  
  public void end(InterpretationContext ec, String e) {}
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.LevelAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.util.OptionHelper;
import org.xml.sax.Attributes;

public class LoggerAction
  extends Action
{
  boolean inError = false;
  
  public void begin(InterpretationContext ec, String name, Attributes attributes)
  {
    inError = false;
    
    LoggerContext loggerContext = (LoggerContext)context;
    
    String loggerName = attributes.getValue("name");
    if (OptionHelper.isEmpty(loggerName))
    {
      inError = true;
      
      String line = ", around line " + getLineNumber(ec) + " column " + getColumnNumber(ec);
      
      String errorMsg = "No 'name' attribute in element " + name + line;
      addError(errorMsg);
      
      return;
    }
    Logger l = loggerContext.getLogger(loggerName);
    
    boolean additive = OptionHelper.toBoolean(attributes.getValue("additivity"), true);
    
    l.setAdditive(additive);
    
    ec.pushObject(l);
  }
  
  public void end(InterpretationContext ec, String e)
  {
    if (!inError) {
      ec.popObject();
    }
  }
  
  public void finish(InterpretationContext ec) {}
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.LoggerAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran.action;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import org.xml.sax.Attributes;

public class RootLoggerAction
  extends Action
{
  static final String NAME_ATTR = "name";
  static final String CLASS_ATTR = "class";
  static final String ADDITIVITY_ATTR = "additivity";
  static final String EMPTY_STR = "";
  static final Class[] ONE_STRING_PARAM = { String.class };
  Logger root;
  boolean inError = false;
  
  public void begin(InterpretationContext ec, String name, Attributes attributes)
  {
    inError = false;
    
    LoggerContext loggerContext = (LoggerContext)context;
    root = loggerContext.getLogger("root");
    
    ec.pushObject(root);
  }
  
  public void end(InterpretationContext ec, String name)
  {
    if (inError) {
      return;
    }
    Object o = ec.peekObject();
    if (o != root)
    {
      addWarn("The object on the top the of the stack is not the root logger");
      
      addWarn("It is: " + o);
    }
    else
    {
      ec.popObject();
    }
  }
  
  public void finish(InterpretationContext ec) {}
}

/* Location:
 * Qualified Name:     ch.qos.logback.classic.joran.action.RootLoggerAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package ch.qos.logback.classic.joran;

import ch.qos.logback.classic.helpers.PlatformInfo;
import ch.qos.logback.classic.joran.action.ConfigurationAction;
import ch.qos.logback.classic.joran.action.ConsolePluginAction;
import ch.qos.logback.classic.joran.action.EvaluatorAction;
import ch.qos.logback.classic.joran.action.JMXConfiguratorAction;
import ch.qos.logback.classic.joran.action.LayoutAction;
import ch.qos.logback.classic.joran.action.LevelAction;
import ch.qos.logback.classic.joran.action.LoggerAction;
import ch.qos.logback.classic.joran.action.RootLoggerAction;
import ch.qos.logback.core.joran.JoranConfiguratorBase;
import ch.qos.logback.core.joran.action.AppenderRefAction;
import ch.qos.logback.core.joran.action.IncludeAction;
import ch.qos.logback.core.joran.action.MatcherAction;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.joran.spi.RuleStore;

public class JoranConfigurator
  extends JoranConfiguratorBase
{
  public void addInstanceRules(RuleStore rs)
  {
    super.addInstanceRules(rs);
    
    rs.addRule(new Pattern("configuration"), new ConfigurationAction());
    
    rs.addRule(new Pattern("*/evaluator"), new EvaluatorAction());
    rs.addRule(new Pattern("*/evaluator/matcher"), new MatcherAction());
    
    rs.addRule(new Pattern("configuration/logger"), new LoggerAction());
    rs.addRule(new Pattern("configuration/logger/level"), new LevelAction());
    
    rs.addRule(new Pattern("configuration/root"), new RootLoggerAction());
    rs.addRule(new Pattern("configuration/root/level"), new LevelAction());
    rs.addRule(new Pattern("configuration/logger/appender-ref"), new AppenderRefAction());
    
    rs.addRule(new Pattern("configuration/root/appender-ref"), new Appe
1 2 3 4 5

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