當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。