/** * Appends in the following format: key=double quoted value. * * @param sb a string builder * @param entry a map entry * @return {@code key="value"} */ public static StringBuilder appendKeyDqValue(final StringBuilder sb, final Entry<String, String> entry) { return appendKeyDqValue(sb, entry.getKey(), entry.getValue()); }
/** * Print the thread information. * @param sb The StringBuilder. */ @Override public void printThreadInfo(final StringBuilder sb) { StringBuilders.appendDqValue(sb, name).append(Chars.SPACE); if (isDaemon) { sb.append("daemon "); } sb.append("prio=").append(priority).append(" tid=").append(id).append(' '); if (threadGroupName != null) { StringBuilders.appendKeyDqValue(sb, "group", threadGroupName); } sb.append('\n'); sb.append("\tThread state: ").append(state.name()).append('\n'); }
/** * Appends in the following format: key=double quoted value. * * @param sb a string builder * @param entry a map entry * @return {@code key="value"} */ public static StringBuilder appendKeyDqValue(final StringBuilder sb, final Entry<String, String> entry) { return appendKeyDqValue(sb, entry.getKey(), entry.getValue()); }
/** * Print the thread information. * @param sb The StringBuilder. */ @Override public void printThreadInfo(final StringBuilder sb) { StringBuilders.appendDqValue(sb, name).append(Chars.SPACE); if (isDaemon) { sb.append("daemon "); } sb.append("prio=").append(priority).append(" tid=").append(id).append(' '); if (threadGroupName != null) { StringBuilders.appendKeyDqValue(sb, "group", threadGroupName); } sb.append('\n'); sb.append("\tThread state: ").append(state.name()).append('\n'); }
protected void asJava(final StringBuilder sb) { sb.append('{'); for (int i = 0; i < data.size(); i++) { if (i > 0) { sb.append(", "); } StringBuilders.appendKeyDqValue(sb, data.getKeyAt(i), data.getValueAt(i)); } sb.append('}'); }
private void appendMap(final String prefix, final Map<String, String> map, final StringBuilder sb, final ListChecker checker) { final SortedMap<String, String> sorted = new TreeMap<>(map); for (final Map.Entry<String, String> entry : sorted.entrySet()) { if (checker.check(entry.getKey()) && entry.getValue() != null) { sb.append(' '); if (prefix != null) { sb.append(prefix); } final String safeKey = escapeNewlines(escapeSDParams(entry.getKey()), escapeNewLine); final String safeValue = escapeNewlines(escapeSDParams(entry.getValue()), escapeNewLine); StringBuilders.appendKeyDqValue(sb, safeKey, safeValue); } } }
protected void appendMap(final StringBuilder sb) { for (int i = 0; i < data.size(); i++) { if (i > 0) { sb.append(' '); } StringBuilders.appendKeyDqValue(sb, data.getKeyAt(i), data.getValueAt(i)); } }
@Override public Object visit(final Configuration configuration, final Node node, final LogEvent event, final StringBuilder log) { final String overridden = this.annotation.value(); final String name = overridden.isEmpty() ? this.member.getName() : overridden; final Map<String, String> attributes = node.getAttributes(); final String rawValue = removeAttributeValue(attributes, name, this.aliases); final String replacedValue = this.substitutor.replace(event, rawValue); final Object value = convert(replacedValue, null); final Object debugValue = this.annotation.sensitive() ? NameUtil.md5(value + this.getClass().getName()) : value; StringBuilders.appendKeyDqValue(log, name, debugValue); return value; } }
@Override public Object visit(final Configuration configuration, final Node node, final LogEvent event, final StringBuilder log) { final String name = this.annotation.value(); final Map<String, String> attributes = node.getAttributes(); final String rawValue = removeAttributeValue(attributes, name, this.aliases); final String replacedValue = this.substitutor.replace(event, rawValue); final Object defaultValue = findDefaultValue(event); final Object value = convert(replacedValue, defaultValue); final Object debugValue = this.annotation.sensitive() ? NameUtil.md5(value + this.getClass().getName()) : value; StringBuilders.appendKeyDqValue(log, name, debugValue); return value; }
@Override public Object visit(final Configuration configuration, final Node node, final LogEvent event, final StringBuilder log) { final String name = this.annotation.value(); final String elementValue = node.getValue(); final String attributeValue = node.getAttributes().get("value"); String rawValue = null; // if neither is specified, return null (LOG4J2-1313) if (Strings.isNotEmpty(elementValue)) { if (Strings.isNotEmpty(attributeValue)) { LOGGER.error("Configuration contains {} with both attribute value ({}) AND element" + " value ({}). Please specify only one value. Using the element value.", node.getName(), attributeValue, elementValue); } rawValue = elementValue; } else { rawValue = removeAttributeValue(node.getAttributes(), "value"); } final String value = this.substitutor.replace(event, rawValue); StringBuilders.appendKeyDqValue(log, name, value); return value; } }