本文整理汇总了Java中org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser方法的典型用法代码示例。如果您正苦于以下问题:Java PatternLayout.createPatternParser方法的具体用法?Java PatternLayout.createPatternParser怎么用?Java PatternLayout.createPatternParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.layout.PatternLayout
的用法示例。
在下文中一共展示了PatternLayout.createPatternParser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Creates a new instance of the class. Required by Log4J2.
*
* @param config the configuration
* @param options the options
* @return a new instance, or {@code null} if the options are invalid
*/
public static ColorConverter newInstance(Configuration config, String[] options) {
if (options.length < 1) {
LOGGER.error("Incorrect number of options on style. "
+ "Expected at least 1, received {}", options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on style");
return null;
}
PatternParser parser = PatternLayout.createPatternParser(config);
List<PatternFormatter> formatters = parser.parse(options[0]);
AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1]));
return new ColorConverter(formatters, element);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:ColorConverter.java
示例2: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config The current Configuration.
* @param options pattern options, may be null. If first element is "short",
* only the first line of the throwable will be formatted.
* @return instance of class.
*/
public static StyleConverter newInstance(final Configuration config, final String[] options) {
if (options.length < 1) {
LOGGER.error("Incorrect number of options on style. Expected at least 1, received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on style");
return null;
}
if (options[1] == null) {
LOGGER.error("No style attributes provided");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
final String style = AnsiEscape.createSequence(options[1].split("\\s*,\\s*"));
return new StyleConverter(formatters, style);
}
示例3: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config The current Configuration.
* @param options pattern options, may be null. If first element is "short",
* only the first line of the throwable will be formatted.
* @return instance of class.
*/
public static RegexReplacementConverter newInstance(final Configuration config, final String[] options) {
if (options.length != 3) {
LOGGER.error("Incorrect number of options on replace. Expected 3 received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on replace");
return null;
}
if (options[1] == null) {
LOGGER.error("No regular expression supplied on replace");
return null;
}
if (options[2] == null) {
LOGGER.error("No substitution supplied on replace");
return null;
}
final Pattern p = Pattern.compile(options[1]);
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new RegexReplacementConverter(formatters, p, options[2]);
}
示例4: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Creates an EncodingPatternConverter using a pattern string and an optional escape format.
*
* @param config the current Configuration
* @param options first option is the nested pattern format; second option is the escape format (optional)
* @return instance of pattern converter.
*/
public static EncodingPatternConverter newInstance(final Configuration config, final String[] options) {
if (options.length > 2 || options.length == 0) {
LOGGER.error("Incorrect number of options on escape. Expected 1 or 2, but received {}",
options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on escape");
return null;
}
final EscapeFormat escapeFormat = options.length < 2 ? EscapeFormat.HTML
: EnglishEnums.valueOf(EscapeFormat.class, options[1], EscapeFormat.HTML);
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new EncodingPatternConverter(formatters, escapeFormat);
}
示例5: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config
* The current Configuration.
* @param options
* pattern options, may be null. If first element is "short", only the first line of the throwable will
* be formatted.
* @return instance of class.
*/
public static StyleConverter newInstance(final Configuration config, final String[] options) {
if (options == null) {
return null;
}
if (options.length < 2) {
LOGGER.error("Incorrect number of options on style. Expected at least 1, received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied for style converter");
return null;
}
if (options[1] == null) {
LOGGER.error("No style attributes supplied for style converter");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
final String style = AnsiEscape.createSequence(options[1].split(Patterns.COMMA_SEPARATOR));
final boolean disableAnsi = Arrays.toString(options).contains(PatternParser.DISABLE_ANSI + "=true");
final boolean noConsoleNoAnsi = Arrays.toString(options).contains(PatternParser.NO_CONSOLE_NO_ANSI + "=true");
final boolean hideAnsi = disableAnsi || (noConsoleNoAnsi && System.console() == null);
return new StyleConverter(formatters, style, hideAnsi);
}
示例6: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config The current Configuration.
* @param options pattern options, an array of two elements: pattern, max length (defaults to 100 on invalid value).
* @return instance of class.
*/
public static MaxLengthConverter newInstance(final Configuration config, final String[] options) {
if (options.length != 2) {
LOGGER.error("Incorrect number of options on maxLength: expected 2 received {}: {}", options.length,
options);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on maxLength");
return null;
}
if (options[1] == null) {
LOGGER.error("No length supplied on maxLength");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new MaxLengthConverter(formatters, AbstractAppender.parseInt(options[1], 100));
}
示例7: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config The current Configuration.
* @param options pattern options, may be null. If first element is "short", only the first line of the
* throwable will be formatted.
* @return instance of class.
*/
public static HighlightConverter newInstance(final Configuration config, final String[] options) {
if (options.length < 1) {
LOGGER.error("Incorrect number of options on style. Expected at least 1, received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on style");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
final boolean disableAnsi = Arrays.toString(options).contains(PatternParser.DISABLE_ANSI + "=true");
final boolean noConsoleNoAnsi = Arrays.toString(options).contains(PatternParser.NO_CONSOLE_NO_ANSI + "=true");
final boolean hideAnsi = disableAnsi || (noConsoleNoAnsi && System.console() == null);
return new HighlightConverter(formatters, createLevelStyleMap(options), hideAnsi);
}
示例8: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config
* The current Configuration.
* @param options
* pattern options, an array of three elements: pattern, testString, and substitution.
* @return instance of class.
*/
public static EqualsIgnoreCaseReplacementConverter newInstance(final Configuration config, final String[] options) {
if (options.length != 3) {
LOGGER.error("Incorrect number of options on equalsIgnoreCase. Expected 3 received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on equalsIgnoreCase");
return null;
}
if (options[1] == null) {
LOGGER.error("No test string supplied on equalsIgnoreCase");
return null;
}
if (options[2] == null) {
LOGGER.error("No substitution supplied on equalsIgnoreCase");
return null;
}
final String p = options[1];
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new EqualsIgnoreCaseReplacementConverter(formatters, p, options[2], parser);
}
示例9: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config The current Configuration.
* @param options pattern options, an array of three elements: pattern, testString, and substitution.
* @return instance of class.
*/
public static EqualsReplacementConverter newInstance(final Configuration config, final String[] options) {
if (options.length != 3) {
LOGGER.error("Incorrect number of options on equals. Expected 3 received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on equals");
return null;
}
if (options[1] == null) {
LOGGER.error("No test string supplied on equals");
return null;
}
if (options[2] == null) {
LOGGER.error("No substitution supplied on equals");
return null;
}
final String p = options[1];
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new EqualsReplacementConverter(formatters, p, options[2], parser);
}
示例10: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Obtains an instance of pattern converter.
*
* @param config The Configuration.
* @param options options, may be null.
* @return instance of pattern converter.
*/
public static SimpleJSONPatternConverter newInstance(final Configuration config, final String[] options) {
if (options.length != 1) {
LOGGER.error("Incorrect number of options on json. Expected 1, received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on json");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new SimpleJSONPatternConverter(formatters);
}
示例11: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config The current Configuration.
* @param options pattern options, may be null. If first element is "short", only the first line of the
* throwable will be formatted.
* @return instance of class.
*/
public static HighlightConverter newInstance(final Configuration config, final String[] options) {
if (options.length < 1) {
LOGGER.error("Incorrect number of options on style. Expected at least 1, received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on style");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new HighlightConverter(formatters, createLevelStyleMap(options));
}
示例12: toPatternFormatterList
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Creates a list of PatternFormatter from the given configuration and options or null if no pattern is supplied.
*
* @param config A configuration.
* @param options pattern options.
* @return a list of PatternFormatter from the given configuration and options or null if no pattern is supplied.
*/
private static List<PatternFormatter> toPatternFormatterList(final Configuration config, final String[] options) {
if (options.length == 0 || options[0] == null) {
LOGGER.error("No pattern supplied on style for config=" + config);
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
if (parser == null) {
LOGGER.error("No PatternParser created for config=" + config + ", options=" + Arrays.toString(options));
return null;
}
return parser.parse(options[0]);
}
示例13: newInstance
import org.apache.logging.log4j.core.layout.PatternLayout; //导入方法依赖的package包/类
/**
* Gets an instance of the class.
*
* @param config
* The current Configuration.
* @param options
* pattern options, may be null.
* @return instance of class.
*/
public static VariablesNotEmptyReplacementConverter newInstance(final Configuration config,
final String[] options) {
if (options.length != 1) {
LOGGER.error("Incorrect number of options on varsNotEmpty. Expected 1 received " + options.length);
return null;
}
if (options[0] == null) {
LOGGER.error("No pattern supplied on varsNotEmpty");
return null;
}
final PatternParser parser = PatternLayout.createPatternParser(config);
final List<PatternFormatter> formatters = parser.parse(options[0]);
return new VariablesNotEmptyReplacementConverter(formatters);
}