PrefixAddingPathMapping(String pathPrefix, PathMapping mapping) { requireNonNull(mapping, "mapping"); // mapping should be GlobPathMapping or RegexPathMapping assert mapping.regex().isPresent() : "unexpected mapping type: " + mapping.getClass().getName(); this.pathPrefix = requireNonNull(pathPrefix, "pathPrefix"); this.mapping = mapping; loggerName = newLoggerName(pathPrefix) + '.' + mapping.loggerName(); meterTag = PREFIX + pathPrefix + ',' + mapping.meterTag(); }
/** * Creates a new instance. */ HttpHeaderPathMapping(PathMapping pathStringMapping, Set<HttpMethod> supportedMethods, List<MediaType> consumeTypes, List<MediaType> produceTypes) { this.pathStringMapping = requireNonNull(pathStringMapping, "pathStringMapping"); this.supportedMethods = requireNonNull(supportedMethods, "supportedMethods"); this.consumeTypes = requireNonNull(consumeTypes, "consumeTypes"); this.produceTypes = requireNonNull(produceTypes, "produceTypes"); loggerName = generateLoggerName(pathStringMapping.loggerName(), supportedMethods, consumeTypes, produceTypes); meterTag = generateMeterTag(pathStringMapping.meterTag(), supportedMethods, consumeTypes, produceTypes); // Starts with 1 due to the HTTP method mapping. int complexity = 1; if (!consumeTypes.isEmpty()) { complexity += 2; } if (!produceTypes.isEmpty()) { complexity += 4; } this.complexity = complexity; }
private RequestContextAwareLogger newLogger(ServiceConfig cfg) { String loggerName = cfg.loggerName().orElse(null); if (loggerName == null) { loggerName = cfg.pathMapping().loggerName(); } return new RequestContextAwareLogger(this, LoggerFactory.getLogger( cfg.server().config().serviceLoggerPrefix() + '.' + loggerName)); }