default: if(currentLiteral.length() != 0) { addToList(new LiteralPatternConverter( currentLiteral.toString())); finalizeConverter(c); state = DOT_STATE; else { finalizeConverter(c); formattingInfo.max = formattingInfo.max*10 + (c - '0'); else { finalizeConverter(c); state = LITERAL_STATE; addToList(new LiteralPatternConverter(currentLiteral.toString()));
/** Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters. @since 0.9.0 */ protected PatternParser createPatternParser(String pattern) { return new PatternParser(pattern); }
/** Set the <b>ConversionPattern</b> option. This is the string which controls formatting and consists of a mix of literal content and conversion specifiers. */ public void setConversionPattern(String conversionPattern) { pattern = conversionPattern; head = createPatternParser(conversionPattern).parse(); }
case 'c': pc = new CategoryPatternConverter(formattingInfo, extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if(dOpt != null) dateFormatStr = dOpt; break; case 'X': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);
@Override protected void finalizeConverter(char c) { PatternConverter pc; switch (c) { case 'm': pc = new PatternConverter(formattingInfo) { @Override protected String convert(LoggingEvent event) { return sanitize(event.getRenderedMessage()); } }; currentLiteral.setLength(0); addConverter(pc); break; default: super.finalizeConverter(c); break; } } };
protected void addConverter(PatternConverter pc) { currentLiteral.setLength(0); // Add the pattern converter to the list. addToList(pc); // Next pattern is assumed to be a literal. state = LITERAL_STATE; // Reset formatting info formattingInfo.reset(); }
/** The option is expected to be in decimal and positive. In case of error, zero is returned. */ protected int extractPrecisionOption() { String opt = extractOption(); int r = 0; if(opt != null) { try { r = Integer.parseInt(opt); if(r <= 0) { LogLog.error( "Precision option (" + opt + ") isn't a positive integer."); r = 0; } } catch (NumberFormatException e) { LogLog.error("Category option \""+opt+"\" not a decimal integer.", e); } } return r; }
@Override protected void addConverter(PatternConverter pc) { try { if (ANSI.isEnabled()) { if (pc.getClass().getName().endsWith("BasicPatternConverter")) { Field typeField = pc.getClass().getDeclaredField("type"); typeField.setAccessible(true); Integer type = (Integer) typeField.get(pc); if (type == 2002) { pc = new ColoredLevelPatternConverter(formattingInfo); } } } } catch (Throwable t) { // ignore } super.addConverter(pc); }
case 'c': pc = new CategoryPatternConverter(formattingInfo, extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if(dOpt != null) dateFormatStr = dOpt; break; case 'X': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);
protected void finalizeConverter(char c) { if (contextCharList.contains(Character.valueOf(c))) { PatternConverter pc = new NFPatternConverter(formattingInfo, c); addConverter(pc); currentLiteral.setLength(0); } else { super.finalizeConverter(c); } }
protected void addConverter(PatternConverter pc) { currentLiteral.setLength(0); // Add the pattern converter to the list. addToList(pc); // Next pattern is assumed to be a literal. state = LITERAL_STATE; // Reset formatting info formattingInfo.reset(); }
/** The option is expected to be in decimal and positive. In case of error, zero is returned. */ protected int extractPrecisionOption() { String opt = extractOption(); int r = 0; if(opt != null) { try { r = Integer.parseInt(opt); if(r <= 0) { LogLog.error( "Precision option (" + opt + ") isn't a positive integer."); r = 0; } } catch (NumberFormatException e) { LogLog.error("Category option \""+opt+"\" not a decimal integer.", e); } } return r; }
case 'c': pc = new CategoryPatternConverter(formattingInfo, extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if(dOpt != null) { dateFormatStr = dOpt; break; case 'X': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);
default: if(currentLiteral.length() != 0) { addToList(new LiteralPatternConverter( currentLiteral.toString())); finalizeConverter(c); state = DOT_STATE; else { finalizeConverter(c); formattingInfo.max = formattingInfo.max*10 + (c - '0'); else { finalizeConverter(c); state = LITERAL_STATE; addToList(new LiteralPatternConverter(currentLiteral.toString()));
/** Constructs a PatternLayout using the supplied conversion pattern. */ public PatternLayout(String pattern) { this.pattern = pattern; head = createPatternParser((pattern == null) ? DEFAULT_CONVERSION_PATTERN : pattern).parse(); }
@Override protected void finalizeConverter(char c) { PatternConverter pc; switch (c) { case 'm': pc = new PatternConverter(formattingInfo) { @Override protected String convert(LoggingEvent event) { return sanitize(event.getRenderedMessage()); } }; currentLiteral.setLength(0); addConverter(pc); break; default: super.finalizeConverter(c); break; } } };
/** Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters. @since 0.9.0 */ protected PatternParser createPatternParser(String pattern) { return new PatternParser(pattern); }
protected void addConverter(PatternConverter pc) { currentLiteral.setLength(0); // Add the pattern converter to the list. addToList(pc); // Next pattern is assumed to be a literal. state = LITERAL_STATE; // Reset formatting info formattingInfo.reset(); }
/** The option is expected to be in decimal and positive. In case of error, zero is returned. */ protected int extractPrecisionOption() { String opt = extractOption(); int r = 0; if(opt != null) { try { r = Integer.parseInt(opt); if(r <= 0) { LogLog.error( "Precision option (" + opt + ") isn't a positive integer."); r = 0; } } catch (NumberFormatException e) { LogLog.error("Category option \""+opt+"\" not a decimal integer.", e); } } return r; }
case 'c': pc = new CategoryPatternConverter(formattingInfo, extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if(dOpt != null) dateFormatStr = dOpt; break; case 'X': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);