java类org.apache.log4j.helpers.PatternConverter的实例源码

PatternLayout.java 文件源码 项目:cacheonix-core 阅读 24 收藏 0 点赞 0 评论 0
/**
   Produces a formatted string as specified by the conversion pattern.
*/
public String format(LoggingEvent event) {
  // Reset working stringbuffer
  if(sbuf.capacity() > MAX_CAPACITY) {
    sbuf = new StringBuffer(BUF_SIZE);
  } else {
    sbuf.setLength(0);
  }

  PatternConverter c = head;

  while(c != null) {
    c.format(sbuf, event);
    c = c.next;
  }
  return sbuf.toString();
}
PatternLayout.java 文件源码 项目:daq-eclipse 阅读 22 收藏 0 点赞 0 评论 0
/**
   Produces a formatted string as specified by the conversion pattern.
*/
public String format(LoggingEvent event) {
  // Reset working stringbuffer
  if(sbuf.capacity() > MAX_CAPACITY) {
    sbuf = new StringBuffer(BUF_SIZE);
  } else {
    sbuf.setLength(0);
  }

  PatternConverter c = head;

  while(c != null) {
    c.format(sbuf, event);
    c = c.next;
  }
  return sbuf.toString();
}
PatternLayout.java 文件源码 项目:nabs 阅读 27 收藏 0 点赞 0 评论 0
/**
   Produces a formatted string as specified by the conversion pattern.
*/
public String format(LoggingEvent event) {
  // Reset working stringbuffer
  if(sbuf.capacity() > MAX_CAPACITY) {
    sbuf = new StringBuffer(BUF_SIZE);
  } else {
    sbuf.setLength(0);
  }

  PatternConverter c = head;

  while(c != null) {
    c.format(sbuf, event);
    c = c.next;
  }
  return sbuf.toString();
}
ExtendedPatternParser.java 文件源码 项目:primecloud-controller 阅读 23 收藏 0 点赞 0 评论 0
@Override
protected void finalizeConverter(char c) {
    PatternConverter pc = null;

    switch (c) {
        case 'H':
            pc = new HeaderPatternConverter(formattingInfo);
            currentLiteral.setLength(0);
            break;
    }

    if (pc != null) {
        addConverter(pc);
    } else {
        super.finalizeConverter(c);
    }
}
EscapedPatternLayout.java 文件源码 项目:further-open-core 阅读 31 收藏 0 点赞 0 评论 0
/**
 * @param c
 * @see org.apache.log4j.helpers.PatternParser#finalizeConverter(char)
 */
@Override
protected void finalizeConverter(final char c)
{
    switch (c)
    {
        case 'm':
        {
            final PatternConverter pc = new EscapedMessagePatternConverter(
                    formattingInfo);
            // LogLog.debug("MESSAGE converter.");
            // formattingInfo.dump();
            currentLiteral.setLength(0);
            addConverter(pc);
            break;
        }

        default:
        {
            super.finalizeConverter(c);
            break;
        }
    }
}
SyncPatternLayout.java 文件源码 项目:commune 阅读 28 收藏 0 点赞 0 评论 0
/**
   Produces a formatted string as specified by the conversion pattern.
 */
public String format(LoggingEvent event) {
    // Reset working stringbuffer
    if(sbuf.capacity() > MAX_CAPACITY) {
        sbuf = new StringBuffer(BUF_SIZE);
    } else {
        sbuf.setLength(0);
    }

    PatternConverter c = head;

    while(c != null) {
        c.format(sbuf, event);
        c = c.next;
    }
    return sbuf.toString();
}
EnhancedPatternLayout.java 文件源码 项目:daq-eclipse 阅读 21 收藏 0 点赞 0 评论 0
/**
 *  Formats a logging event to a writer.
 * @param event logging event to be formatted.
*/
public String format(final LoggingEvent event) {
    StringBuffer buf = new StringBuffer();
    for(PatternConverter c = head;
        c != null;
        c = c.next) {
        c.format(buf, event);
    }
    return buf.toString();
}
FoundationLoggingPatternLayout.java 文件源码 项目:logging 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Formats a logging event to a writer.
 * 
 * @param event
 *            logging event to be formatted.
 */
public String format(final LoggingEvent event) {
    final StringBuffer buf = new StringBuffer();
    for (PatternConverter c = head; c != null; c = c.next) {
        c.format(buf, event);
    }
    return buf.toString();
}
FoundationLoggingPatternConverter.java 文件源码 项目:logging 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Create a new instance.
 * 
 * @param pattern
 *            pattern, may not be null.
 */

public FoundationLoggingPatternConverter(final String pattern) {
    super();
    next = null;
    handlesExceptions = false;

    final List<PatternConverter> converters = new ArrayList<PatternConverter>();
    final List<FormattingInfo> fields = new ArrayList<FormattingInfo>();
    @SuppressWarnings("unchecked")
    final Map converterRegistry = null;

    @SuppressWarnings("unchecked")
    final Map<String, Class<? extends org.apache.log4j.pattern.PatternConverter>> patternLayoutRules = PatternParser.getPatternLayoutRules();
    final Map<String, Class<? extends org.apache.log4j.pattern.PatternConverter>> newPatternLayoutRules = new HashMap<String, Class<? extends org.apache.log4j.pattern.PatternConverter>>();
    newPatternLayoutRules.putAll(patternLayoutRules);
    newPatternLayoutRules.put("throwable", FoundationLoggingThrowableInformationPatternConverter.class);
    newPatternLayoutRules.put("pm", FoundationLoggingMessagePatternConverter.class);
    newPatternLayoutRules.put("sl", FoundationLoggingStructuredMessageConverter.class);
    newPatternLayoutRules.put("prettymessage", FoundationLoggingMessagePatternConverter.class);
    newPatternLayoutRules.put("errorcode", FoundationLoggingErrorCodePatternConverter.class);
    newPatternLayoutRules.put("audit", FoundationLoggingAuditPatternConverter.class);
    newPatternLayoutRules.put("u", FoundationLoggingUserFieldPatternConverter.class);
    newPatternLayoutRules.put("host", FoundationLoggingHostPatternConverter.class);
    newPatternLayoutRules.put("compInstallPath", FoundationLoggingCompInstPathPatternConverter.class);
    newPatternLayoutRules.put("compVersion", FoundationLoggingCompVersionPatternConverter.class);
    newPatternLayoutRules.put("compName", FoundationLoggingCompNamePatternConverter.class);
    newPatternLayoutRules.put("compInstanceName", FoundationLoggingCompInstNamePatternConverter.class);

    PatternParser.parse(pattern, converters, fields, converterRegistry, newPatternLayoutRules);

    patternConverters = new LoggingEventPatternConverter[converters.size()];
    patternFields = new FormattingInfo[converters.size()];

    int index = 0;
    final Iterator<PatternConverter> converterIter = converters.iterator();
    final Iterator<FormattingInfo> fieldIter = fields.iterator();

    while (converterIter.hasNext()) {
        final Object converter = converterIter.next();

        if (converter instanceof LoggingEventPatternConverter) {
            patternConverters[index] = (LoggingEventPatternConverter) converter;
            handlesExceptions |= patternConverters[index].handlesThrowable();
        } else {
            patternConverters[index] = new org.apache.log4j.pattern.LiteralPatternConverter("");
        }

        if (fieldIter.hasNext()) {
            patternFields[index] = fieldIter.next();
        } else {
            patternFields[index] = FormattingInfo.getDefault();
        }

        index++;
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号