Slf4jReporterConfig.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:carbon-metrics 作者:
/**
 * Build the SLF4J Reporter
 *
 * @param metricRegistry The {@link MetricRegistry} for the reporter
 * @param metricFilter   The {@link MetricFilter} for the reporter
 * @return an {@link Optional} with {@link Slf4jReporter}, if the reporter is built successfully, otherwise an empty
 * {@code Optional}
 * @throws ReporterBuildException when there was a failure in constructing the reporter
 */
@Override
public Optional<Slf4jReporter> build(MetricRegistry metricRegistry, MetricFilter metricFilter)
        throws ReporterBuildException {
    if (!isEnabled()) {
        return Optional.empty();
    }
    if (loggerName == null || loggerName.trim().isEmpty()) {
        throw new ReporterBuildException("Logger Name is not specified for SLF4J Reporting.");
    }

    if (logger.isInfoEnabled()) {
        logger.info(String.format(
                "Creating SLF4J reporter for Metrics with logger name '%s' and %d seconds polling period",
                loggerName, getPollingPeriod()));
    }

    return Optional.of(new Slf4jReporter(getName(), metricRegistry, getFilter(metricFilter), loggerName, markerName,
            getPollingPeriod()));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号