org.slf4j.helpers.BasicMarkerFactory Java Examples

The following examples show how to use org.slf4j.helpers.BasicMarkerFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogbackUtilTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddMarker() throws Exception {
  //given
  final Marker marker = new BasicMarkerFactory().getMarker("some marker");

  //when
  LogbackUtil.addMarker(marker, new HashMap<>(), builder);

  //then
  assertEquals(builder.build().getMarkerColors(), MarkerColors.Aqua);
  assertTrue(builder.build().isMarked());
  assertEquals(builder.build().getProperties().get("marker"), "some marker");
}
 
Example #2
Source File: StartReportingMetricsToSLF4JBuilder.java    From kite with Apache License 2.0 5 votes vote down vote up
public StartReportingMetricsToSLF4J(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
  super(builder, config, parent, child, context);      
  
  MetricFilter filter = PatternMetricFilter.parse(getConfigs(), config);
  TimeUnit defaultDurationUnit = getConfigs().getTimeUnit(config, "defaultDurationUnit", TimeUnit.MILLISECONDS);
  TimeUnit defaultRateUnit = getConfigs().getTimeUnit(config, "defaultRateUnit", TimeUnit.SECONDS); 
  long frequency = getConfigs().getNanoseconds(config, "frequency", 10 * 1000L * 1000 * 1000); // 10 secs, also see https://github.com/typesafehub/config/blob/master/HOCON.md#duration-format
  this.logger = getConfigs().getString(config, "logger", "metrics");
  String marker = getConfigs().getString(config, "marker", null);      
  validateArguments();
  
  MetricRegistry registry = context.getMetricRegistry();
  synchronized (REGISTRIES) {
    Map<String, Slf4jReporter> reporters = REGISTRIES.get(registry);
    if (reporters == null) {
      reporters = Maps.newHashMap();
      REGISTRIES.put(registry, reporters);
    }
    Slf4jReporter reporter = reporters.get(logger);
    if (reporter == null) {
      Builder reporterBuilder = Slf4jReporter.forRegistry(registry)
          .filter(filter)
          .convertDurationsTo(defaultDurationUnit)
          .convertRatesTo(defaultRateUnit)
          .outputTo(LoggerFactory.getLogger(logger));
      
      if (marker != null) {
        reporterBuilder = reporterBuilder.markWith(new BasicMarkerFactory().getMarker(marker));
      }
          
      reporter = reporterBuilder.build();
      reporter.start(frequency, TimeUnit.NANOSECONDS);
      reporters.put(logger, reporter);
    }
  }
}
 
Example #3
Source File: StaticMarkerBinder.java    From HttpSessionReplacer with MIT License 4 votes vote down vote up
/**
 * Currently, this method returns the class name of
 * {@link BasicMarkerFactory}.
 */
@Override
public String getMarkerFactoryClassStr() {
    return BasicMarkerFactory.class.getName();
}
 
Example #4
Source File: StaticMarkerBinder.java    From ymate-platform-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public String getMarkerFactoryClassStr() {
    return BasicMarkerFactory.class.getName();
}
 
Example #5
Source File: DefaultLoggerServiceProvider.java    From core-ng-project with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    loggerFactory = new DefaultLoggerFactory();
    markerFactory = new BasicMarkerFactory();
    mdcAdapter = new NOPMDCAdapter();
}
 
Example #6
Source File: StaticMarkerBinder.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
public String getMarkerFactoryClassStr() {
    return BasicMarkerFactory.class.getName();
}
 
Example #7
Source File: Slf4jEclipseLoggerServiceProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize() {
	this.loggerFactory = new Slf4jEclipseLoggerFactory();
	this.markerFactory = new BasicMarkerFactory();
	this.mdc = new BasicMDCAdapter();
}
 
Example #8
Source File: StaticMarkerBinder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getMarkerFactoryClassStr() {
  return BasicMarkerFactory.class.getName();
}
 
Example #9
Source File: StaticMarkerBinder.java    From joynr with Apache License 2.0 4 votes vote down vote up
/**
 * Currently, this method returns the class name of
 * {@link BasicMarkerFactory}.
 */
@Override
public String getMarkerFactoryClassStr() {
    return BasicMarkerFactory.class.getName();
}
 
Example #10
Source File: StaticMarkerBinder.java    From xltsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Currently, this method returns the class name of
 * {@link BasicMarkerFactory}.
 */
public String getMarkerFactoryClassStr() {
  return BasicMarkerFactory.class.getName();
}