Dedicated, "_"-prefixed log category for request mappings
Closes gh-26539
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -128,12 +128,15 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
|
||||
}
|
||||
|
||||
private void logRouterFunctions(List<RouterFunction<?>> routerFunctions) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (mappingsLogger.isDebugEnabled()) {
|
||||
routerFunctions.forEach(function -> mappingsLogger.debug("Mapped " + function));
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
int total = routerFunctions.size();
|
||||
String message = total + " RouterFunction(s) in " + formatMappingName();
|
||||
if (logger.isTraceEnabled()) {
|
||||
if (total > 0) {
|
||||
routerFunctions.forEach(routerFunction -> logger.trace("Mapped " + routerFunction));
|
||||
routerFunctions.forEach(function -> logger.trace("Mapped " + function));
|
||||
}
|
||||
else {
|
||||
logger.trace(message);
|
||||
|
||||
@@ -18,11 +18,13 @@ package org.springframework.web.reactive.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.context.support.ApplicationObjectSupport;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.log.LogDelegateFactory;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -51,6 +53,10 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport
|
||||
|
||||
private static final WebHandler NO_OP_HANDLER = exchange -> Mono.empty();
|
||||
|
||||
/** Dedicated "hidden" logger for request mappings. */
|
||||
protected final Log mappingsLogger =
|
||||
LogDelegateFactory.getHiddenLog(HandlerMapping.class.getName() + ".Mappings");
|
||||
|
||||
|
||||
private final PathPatternParser patternParser;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -158,9 +158,16 @@ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
|
||||
}
|
||||
registerHandler(url, handler);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Patterns " + getHandlerMap().keySet() + " in " + formatMappingName());
|
||||
}
|
||||
logMappings();
|
||||
}
|
||||
}
|
||||
|
||||
private void logMappings() {
|
||||
if (mappingsLogger.isDebugEnabled()) {
|
||||
mappingsLogger.debug(formatMappingName() + " " + getHandlerMap());
|
||||
}
|
||||
else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Patterns " + getHandlerMap().keySet() + " in " + formatMappingName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -619,7 +619,9 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||
return this.locationValues.stream().collect(Collectors.joining("\", \"", "[\"", "\"]"));
|
||||
}
|
||||
else if (!this.locations.isEmpty()) {
|
||||
return "[" + this.locations + "]";
|
||||
return "[" + this.locations.toString()
|
||||
.replaceAll("class path resource", "Classpath")
|
||||
.replaceAll("ServletContext resource", "ServletContext") + "]";
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -211,6 +211,9 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace(formatMappings(userType, methods));
|
||||
}
|
||||
else if (mappingsLogger.isDebugEnabled()) {
|
||||
mappingsLogger.debug(formatMappings(userType, methods));
|
||||
}
|
||||
methods.forEach((method, mapping) -> {
|
||||
Method invocableMethod = AopUtils.selectInvocableMethod(method, userType);
|
||||
registerHandlerMethod(handler, invocableMethod, mapping);
|
||||
|
||||
Reference in New Issue
Block a user