当前位置: 首页>>代码示例>>Java>>正文


Java Filter类代码示例

本文整理汇总了Java中ch.qos.logback.core.filter.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Filter类属于ch.qos.logback.core.filter包,在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAbstractAndConsole

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
/**
 * Test abstract functions (using console implementation) and the functions
 * of console
 *
 */
@Test
public void testAbstractAndConsole() {
	BaleenConsoleLoggerBuilder builder = new BaleenConsoleLoggerBuilder(NAME, BaleenLogging.DEFAULT_PATTERN,
			new MinMaxFilter(Level.INFO, Level.WARN));

	LoggerContext context = new LoggerContext();
	Encoder<ILoggingEvent> encoder = new PatternLayoutEncoder();

	Appender<ILoggingEvent> appender = builder.build(context, encoder);

	assertEquals(NAME, builder.getName());

	assertTrue(appender instanceof ConsoleAppender);
	assertEquals(encoder, ((ConsoleAppender<ILoggingEvent>) appender).getEncoder());

	assertNotNull(appender);
	assertEquals(NAME, appender.getName());
	Filter<ILoggingEvent> filter = appender.getCopyOfAttachedFiltersList().get(0);
	assertTrue(filter instanceof MinMaxFilter);
	assertEquals(Level.INFO, ((MinMaxFilter) filter).getMin());
	assertEquals(Level.WARN, ((MinMaxFilter) filter).getMax());
}
 
开发者ID:dstl,项目名称:baleen,代码行数:28,代码来源:BaleenLoggerBuilderTest.java

示例2: startAndAddFilter

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
private void startAndAddFilter(Filter<ILoggingEvent> filter) {
    if (filter != null) {
        if (!filter.isStarted()) {
            filter.start();
        }
        addFilter(filter);
    }
}
 
开发者ID:symphoniacloud,项目名称:lambda-monitoring,代码行数:9,代码来源:LambdaConsoleAppender.java

示例3: getFilterChainDecision

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
/**
 * Loop through the filters in the list. As soon as a filter decides on
 * ACCEPT or DENY, then that value is returned. If all of the filters return
 * NEUTRAL, then NEUTRAL is returned.
 */
public FilterReply getFilterChainDecision(E event) {
  for (Filter<E> f : filterList) {
    final FilterReply r = f.decide(event);
    if (r == FilterReply.DENY || r == FilterReply.ACCEPT) {
      return r;
    }
  }
  return FilterReply.NEUTRAL;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:15,代码来源:FilterAttachableImpl.java

示例4: configureFilters

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
private List<Filter<ILoggingEvent>> configureFilters(Map<String, Object> config) throws InvalidParameterException {
	List<Filter<ILoggingEvent>> filters = new ArrayList<>();
	
	List<String> includeLoggers = yamlToList(config.get("includeLoggers"));
	List<String> excludeLoggers = yamlToList(config.get("excludeLoggers"));

	if (!includeLoggers.isEmpty()) {
		LoggerFilter includeFilter = new LoggerFilter(includeLoggers, false);
		filters.add(includeFilter);
	}

	if (!excludeLoggers.isEmpty()) {
		LoggerFilter excludeFilter = new LoggerFilter(excludeLoggers, true);
		filters.add(excludeFilter);
	}
	
	String minLevelStr = (String) config.get("minLevel");
	String maxLevelStr = (String) config.get("maxLevel");
	
	Level minLevel = convertToLevel(minLevelStr);
	Level maxLevel = convertToLevel(maxLevelStr);

	MinMaxFilter levelFilter = new MinMaxFilter(minLevel, maxLevel);
	filters.add(levelFilter);
	
	return filters;
}
 
开发者ID:dstl,项目名称:baleen,代码行数:28,代码来源:BaleenLogging.java

示例5: configureLogger

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
private BaleenLoggerBuilder configureLogger(Map<String, Object> config) throws InvalidParameterException {
	// Extract the specified configuration parameters
	String name = (String) config.get("name");
	String pattern = (String) config.getOrDefault("pattern", DEFAULT_PATTERN);

	String file = (String) config.get("file");
	Boolean rolling = (Boolean) config.getOrDefault("daily", false);

	Double maxSize = parseToDouble(config.get("size"));
	Integer maxHistory = (Integer) config.get("history");

	List<Filter<ILoggingEvent>> filters = configureFilters(config);

	// Do we have a name, and if so is it a special case (e.g. console)
	if (Strings.isNullOrEmpty(name)) {
		LOGGER.warn("Required parameter 'name' not specified for logger - logger will be skipped");
		return null;
	} else if ("console".equalsIgnoreCase(name)) {
		return new BaleenConsoleLoggerBuilder(name, pattern, filters);
	} else {
		if (Strings.isNullOrEmpty(file)) {
			file = name;
		}

		Optional<Integer> integerMaxSize = Optional.empty();
		if (maxSize != null) {
			integerMaxSize = Optional.of((int) (maxSize * 1024));
		}
		return new BaleenFileLoggerBuilder(name, pattern, file, filters, rolling, integerMaxSize, Optional
				.ofNullable(maxHistory));
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:33,代码来源:BaleenLogging.java

示例6: testNullFilters

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Test
public void testNullFilters() {
	BaleenConsoleLoggerBuilder singleBuilder = new BaleenConsoleLoggerBuilder(BaleenLogging.DEFAULT_PATTERN,
			(Filter<ILoggingEvent>) null);
	List<Filter<ILoggingEvent>> list = null;
	BaleenConsoleLoggerBuilder listBuilder = new BaleenConsoleLoggerBuilder(BaleenLogging.DEFAULT_PATTERN, list);

	singleBuilder.build(null, null);
	listBuilder.build(null, null);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:11,代码来源:BaleenLoggerBuilderTest.java

示例7: testAbstractAndConsoleMultipleFilters

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Test
public void testAbstractAndConsoleMultipleFilters() {
	BaleenConsoleLoggerBuilder builder = new BaleenConsoleLoggerBuilder(NAME, BaleenLogging.DEFAULT_PATTERN,
			Arrays.asList(new MinMaxFilter(Level.INFO, Level.ERROR), new MinMaxFilter(Level.INFO, Level.WARN)));

	LoggerContext context = new LoggerContext();
	Encoder<ILoggingEvent> encoder = new PatternLayoutEncoder();

	Appender<ILoggingEvent> appender = builder.build(context, encoder);

	assertEquals(NAME, builder.getName());

	assertTrue(appender instanceof ConsoleAppender);
	assertEquals(encoder, ((ConsoleAppender<ILoggingEvent>) appender).getEncoder());

	assertNotNull(appender);
	assertEquals(NAME, appender.getName());
	assertEquals(2, appender.getCopyOfAttachedFiltersList().size());
	Filter<ILoggingEvent> filter = appender.getCopyOfAttachedFiltersList().get(0);
	assertTrue(filter instanceof MinMaxFilter);
	assertEquals(Level.INFO, ((MinMaxFilter) filter).getMin());
	assertEquals(Level.ERROR, ((MinMaxFilter) filter).getMax());

	filter = appender.getCopyOfAttachedFiltersList().get(1);
	assertTrue(filter instanceof MinMaxFilter);
	assertEquals(Level.INFO, ((MinMaxFilter) filter).getMin());
	assertEquals(Level.WARN, ((MinMaxFilter) filter).getMax());

	// TODO: Test that both filters are being applied
}
 
开发者ID:dstl,项目名称:baleen,代码行数:31,代码来源:BaleenLoggerBuilderTest.java

示例8: getCopyOfAttachedFiltersList

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Override
public List<Filter<ILoggingEvent>> getCopyOfAttachedFiltersList() {
  return null;
}
 
开发者ID:mustaine,项目名称:logcapture,代码行数:5,代码来源:StubAppender.java

示例9: getCopyOfAttachedFiltersList

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Override
public List<Filter<E>> getCopyOfAttachedFiltersList() {
    return null;
}
 
开发者ID:gchq,项目名称:stroom-query,代码行数:5,代码来源:FifoLogbackAppender.java

示例10: LambdaConsoleAppender

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public LambdaConsoleAppender(String pattern, Filter<ILoggingEvent> filter) {
    this();
    addPattern(pattern);
    startAndAddFilter(filter);
}
 
开发者ID:symphoniacloud,项目名称:lambda-monitoring,代码行数:6,代码来源:LambdaConsoleAppender.java

示例11: addFilter

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public void addFilter(Filter<E> newFilter) {
  fai.addFilter(newFilter);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:AppenderBase.java

示例12: getCopyOfAttachedFiltersList

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public List<Filter<E>> getCopyOfAttachedFiltersList() {
  return fai.getCopyOfAttachedFiltersList();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:AppenderBase.java

示例13: addFilter

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
/**
 * Add a filter to end of the filter list.
 */
public void addFilter(Filter<E> newFilter) {
  filterList.add(newFilter);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:7,代码来源:FilterAttachableImpl.java

示例14: getCopyOfAttachedFiltersList

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public List<Filter<E>> getCopyOfAttachedFiltersList() {
  return new ArrayList<Filter<E>>(filterList);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:FilterAttachableImpl.java

示例15: addFilter

import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Override
public void addFilter(Filter<IAccessEvent> newFilter) {
  fai.addFilter(newFilter);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:5,代码来源:AccessContext.java


注:本文中的ch.qos.logback.core.filter.Filter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。