public void testHomonyms() { final String diffPrefix = "homonym" + diff; final String PARENT_NAME = diffPrefix + PARENT_MARKER_STR; final String CHILD_NAME = diffPrefix + CHILD_MARKER_STR; Marker parent = factory.getMarker(PARENT_NAME); Marker child = factory.getMarker(CHILD_NAME); parent.add(child); IMarkerFactory otherFactory = new BasicMarkerFactory(); Marker otherParent = otherFactory.getMarker(PARENT_NAME); Marker otherChild = otherFactory.getMarker(CHILD_NAME); assertTrue(parent.contains(otherParent)); assertTrue(parent.contains(otherChild)); assertTrue(parent.remove(otherChild)); }
@Test public void testMarker() { Logger logger = LoggerFactory.getLogger("testMarker"); IMarkerFactory markerFactory = new BasicMarkerFactory(); Marker blue = markerFactory.getMarker("BLUE"); logger.debug(blue, "hello"); logger.info(blue, "hello"); logger.warn(blue, "hello"); logger.error(blue, "hello"); logger.debug(blue, "hello {}", "world"); logger.info(blue, "hello {}", "world"); logger.warn(blue, "hello {}", "world"); logger.error(blue, "hello {}", "world"); logger.debug(blue, "hello {} and {} ", "world", "universe"); logger.info(blue, "hello {} and {} ", "world", "universe"); logger.warn(blue, "hello {} and {} ", "world", "universe"); logger.error(blue, "hello {} and {} ", "world", "universe"); }
public BasicMarkerTest() { factory = new BasicMarkerFactory(); blue = factory.getMarker(BLUE_STR); red = factory.getMarker(RED_STR); green = factory.getMarker(GREEN_STR); comp = factory.getMarker(COMP_STR); comp.add(blue); multiComp = factory.getMarker(MULTI_COMP_STR); multiComp.add(green); multiComp.add(comp); }
@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"); }
@Test public void logMarker() throws InterruptedException { Marker sendEmailMarker = new BasicMarkerFactory().getMarker("SEND_EMAIL"); LOG.debug(sendEmailMarker, "Test the marker 1."); LOG.debug(sendEmailMarker, "Test the marker 2."); Thread.sleep(1000); }
@Test public void logNestedMarker() throws InterruptedException { Marker notifyMarker = new BasicMarkerFactory().getMarker("NOTIFY"); Marker sendEmailMarker = new BasicMarkerFactory().getMarker("SEND_EMAIL"); sendEmailMarker.add(notifyMarker); LOG.debug(sendEmailMarker, "Test the nested marker 1."); LOG.debug(sendEmailMarker, "Test the nested marker 2."); Thread.sleep(1000); }
@Test public void testIsArrayStenoEvent() throws Exception { final Marker rootMarker = new BasicMarkerFactory().getMarker("foo"); rootMarker.add(StenoMarker.ARRAY_MARKER); Assert.assertTrue(_encoder.isArrayStenoEvent(StenoMarker.ARRAY_MARKER)); Assert.assertTrue(_encoder.isArrayStenoEvent(rootMarker)); Assert.assertFalse(_encoder.isArrayStenoEvent(StenoMarker.ARRAY_JSON_MARKER)); Assert.assertFalse(_encoder.isArrayStenoEvent(StenoMarker.MAP_MARKER)); Assert.assertFalse(_encoder.isArrayStenoEvent(StenoMarker.MAP_JSON_MARKER)); Assert.assertFalse(_encoder.isArrayStenoEvent(StenoMarker.OBJECT_MARKER)); Assert.assertFalse(_encoder.isArrayStenoEvent(StenoMarker.OBJECT_JSON_MARKER)); }
@Test public void testIsArrayJsonStenoEvent() throws Exception { final Marker rootMarker = new BasicMarkerFactory().getMarker("foo"); rootMarker.add(StenoMarker.ARRAY_JSON_MARKER); Assert.assertTrue(_encoder.isArrayJsonStenoEvent(StenoMarker.ARRAY_JSON_MARKER)); Assert.assertTrue(_encoder.isArrayJsonStenoEvent(rootMarker)); Assert.assertFalse(_encoder.isArrayJsonStenoEvent(StenoMarker.ARRAY_MARKER)); Assert.assertFalse(_encoder.isArrayJsonStenoEvent(StenoMarker.MAP_MARKER)); Assert.assertFalse(_encoder.isArrayJsonStenoEvent(StenoMarker.MAP_JSON_MARKER)); Assert.assertFalse(_encoder.isArrayJsonStenoEvent(StenoMarker.OBJECT_MARKER)); Assert.assertFalse(_encoder.isArrayJsonStenoEvent(StenoMarker.OBJECT_JSON_MARKER)); }
@Test public void testIsMapStenoEvent() throws Exception { final Marker rootMarker = new BasicMarkerFactory().getMarker("foo"); rootMarker.add(StenoMarker.MAP_MARKER); Assert.assertTrue(_encoder.isMapStenoEvent(StenoMarker.MAP_MARKER)); Assert.assertTrue(_encoder.isMapStenoEvent(rootMarker)); Assert.assertFalse(_encoder.isMapStenoEvent(StenoMarker.MAP_JSON_MARKER)); Assert.assertFalse(_encoder.isMapStenoEvent(StenoMarker.ARRAY_MARKER)); Assert.assertFalse(_encoder.isMapStenoEvent(StenoMarker.ARRAY_JSON_MARKER)); Assert.assertFalse(_encoder.isMapStenoEvent(StenoMarker.OBJECT_MARKER)); Assert.assertFalse(_encoder.isMapStenoEvent(StenoMarker.OBJECT_JSON_MARKER)); }
@Test public void testIsMapJsonStenoEvent() throws Exception { final Marker rootMarker = new BasicMarkerFactory().getMarker("foo"); rootMarker.add(StenoMarker.MAP_JSON_MARKER); Assert.assertTrue(_encoder.isMapJsonStenoEvent(StenoMarker.MAP_JSON_MARKER)); Assert.assertTrue(_encoder.isMapJsonStenoEvent(rootMarker)); Assert.assertFalse(_encoder.isMapJsonStenoEvent(StenoMarker.MAP_MARKER)); Assert.assertFalse(_encoder.isMapJsonStenoEvent(StenoMarker.ARRAY_MARKER)); Assert.assertFalse(_encoder.isMapJsonStenoEvent(StenoMarker.ARRAY_JSON_MARKER)); Assert.assertFalse(_encoder.isMapJsonStenoEvent(StenoMarker.OBJECT_MARKER)); Assert.assertFalse(_encoder.isMapJsonStenoEvent(StenoMarker.OBJECT_JSON_MARKER)); }
@Test public void testIsObjectStenoEvent() throws Exception { final Marker rootMarker = new BasicMarkerFactory().getMarker("foo"); rootMarker.add(StenoMarker.OBJECT_MARKER); Assert.assertTrue(_encoder.isObjectStenoEvent(StenoMarker.OBJECT_MARKER)); Assert.assertTrue(_encoder.isObjectStenoEvent(rootMarker)); Assert.assertFalse(_encoder.isObjectStenoEvent(StenoMarker.MAP_MARKER)); Assert.assertFalse(_encoder.isObjectStenoEvent(StenoMarker.MAP_JSON_MARKER)); Assert.assertFalse(_encoder.isObjectStenoEvent(StenoMarker.ARRAY_MARKER)); Assert.assertFalse(_encoder.isObjectStenoEvent(StenoMarker.ARRAY_JSON_MARKER)); Assert.assertFalse(_encoder.isObjectStenoEvent(StenoMarker.OBJECT_JSON_MARKER)); }
@Test public void testIsObjectJsonStenoEvent() throws Exception { final Marker rootMarker = new BasicMarkerFactory().getMarker("foo"); rootMarker.add(StenoMarker.OBJECT_JSON_MARKER); Assert.assertTrue(_encoder.isObjectJsonStenoEvent(StenoMarker.OBJECT_JSON_MARKER)); Assert.assertTrue(_encoder.isObjectJsonStenoEvent(rootMarker)); Assert.assertFalse(_encoder.isObjectJsonStenoEvent(StenoMarker.MAP_MARKER)); Assert.assertFalse(_encoder.isObjectJsonStenoEvent(StenoMarker.MAP_JSON_MARKER)); Assert.assertFalse(_encoder.isObjectJsonStenoEvent(StenoMarker.ARRAY_MARKER)); Assert.assertFalse(_encoder.isObjectJsonStenoEvent(StenoMarker.ARRAY_JSON_MARKER)); Assert.assertFalse(_encoder.isObjectJsonStenoEvent(StenoMarker.OBJECT_MARKER)); }
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 = new HashMap(); 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); } } }
/** * Currently, this method returns the class name of * {@link BasicMarkerFactory}. */ @Override public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
/** * {@inheritDoc} */ @Override public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
@Override public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
/** * Currently, this method returns the class name of {@link BasicMarkerFactory}. */ @Override public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
/** * Currently, this method returns the class name of * {@link BasicMarkerFactory}. */ public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
/** * Currently, this method returns the class name of * {@link BasicMarkerFactory}. * * @return the class name */ public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }
/** * Currently, this method returns the class name of * {@link org.slf4j.helpers.BasicMarkerFactory}. */ public String getMarkerFactoryClassStr() { return BasicMarkerFactory.class.getName(); }