From f916e1a1cee3f2e3c81c04f925d59f83c52e9276 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 19 Aug 2019 14:17:50 +0100 Subject: [PATCH] Document response structure for retrieving a logger group Closes gh-17909 --- .../src/main/asciidoc/endpoints/loggers.adoc | 11 +++++++++++ .../LoggersEndpointDocumentationTests.java | 10 +++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/loggers.adoc b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/loggers.adoc index 5c5c4066084..eb8a4945615 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/loggers.adoc +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/loggers.adoc @@ -72,6 +72,17 @@ include::{snippets}loggers/group/http-response.adoc[] +[[loggers-group-response-structure]] +=== Response Structure + +The response contains details of the requested group. The following table describes the +structure of the response: + +[cols="3,1,3"] +include::{snippets}loggers/group/response-fields.adoc[] + + + [[loggers-setting-level]] == Setting a Log Level diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java index 37263c135ca..d575bf9c83b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/LoggersEndpointDocumentationTests.java @@ -37,6 +37,7 @@ import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; import org.springframework.restdocs.payload.FieldDescriptor; +import org.springframework.restdocs.payload.JsonFieldType; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; @@ -62,9 +63,9 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest static { groupLevelFields = Arrays.asList( - fieldWithPath("configuredLevel").description("Configured level of the logger group") - .type(LogLevel.class).optional(), - fieldWithPath("members").description("Loggers that are part of this group").optional()); + fieldWithPath("configuredLevel").description("Configured level of the logger group, if any.") + .type(JsonFieldType.STRING).optional(), + fieldWithPath("members").description("Loggers that are part of this group")); } @MockBean @@ -98,8 +99,11 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest @Test void loggerGroups() throws Exception { + this.loggerGroups.get("test").configureLogLevel(LogLevel.INFO, (member, level) -> { + }); this.mockMvc.perform(get("/actuator/loggers/test")).andExpect(status().isOk()) .andDo(MockMvcRestDocumentation.document("loggers/group", responseFields(groupLevelFields))); + resetLogger(); } @Test