MCPcopy Index your code
hub / github.com/OpenFeign/feign / Slf4jLoggerTest

Class Slf4jLoggerTest

slf4j/src/test/java/feign/slf4j/Slf4jLoggerTest.java:31–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29import org.slf4j.simple.RecordingSimpleLogger;
30
31@SuppressWarnings("deprecation")
32public class Slf4jLoggerTest {
33
34 private static final String CONFIG_KEY = "someMethod()";
35 private static final Request REQUEST =
36 new RequestTemplate()
37 .method(HttpMethod.GET)
38 .target("http://api.example.com")
39 .resolve(Collections.emptyMap())
40 .request();
41 private static final Response RESPONSE =
42 Response.builder()
43 .status(200)
44 .reason("OK")
45 .request(Request.create(HttpMethod.GET, "/api", Collections.emptyMap(), null, Util.UTF_8))
46 .headers(Collections.<String, Collection<String>>emptyMap())
47 .body(new byte[0])
48 .build();
49 public final RecordingSimpleLogger slf4j = new RecordingSimpleLogger();
50 private Slf4jLogger logger;
51
52 @Test
53 void useFeignLoggerByDefault() throws Exception {
54 slf4j.logLevel("debug");
55 slf4j.expectMessages(
56 "DEBUG feign.Logger - [someMethod] This is my message" + System.lineSeparator());
57
58 logger = new Slf4jLogger();
59 logger.log(CONFIG_KEY, "This is my message");
60 }
61
62 @Test
63 void useLoggerByNameIfRequested() throws Exception {
64 slf4j.logLevel("debug");
65 slf4j.expectMessages(
66 "DEBUG named.logger - [someMethod] This is my message" + System.lineSeparator());
67
68 logger = new Slf4jLogger("named.logger");
69 logger.log(CONFIG_KEY, "This is my message");
70 }
71
72 @Test
73 void useLoggerByClassIfRequested() throws Exception {
74 slf4j.logLevel("debug");
75 slf4j.expectMessages(
76 "DEBUG feign.Feign - [someMethod] This is my message" + System.lineSeparator());
77
78 logger = new Slf4jLogger(Feign.class);
79 logger.log(CONFIG_KEY, "This is my message");
80 }
81
82 @Test
83 void useSpecifiedLoggerIfRequested() throws Exception {
84 slf4j.logLevel("debug");
85 slf4j.expectMessages(
86 "DEBUG specified.logger - [someMethod] This is my message" + System.lineSeparator());
87
88 logger = new Slf4jLogger(LoggerFactory.getLogger("specified.logger"));

Callers

nothing calls this directly

Calls 11

builderMethod · 0.95
createMethod · 0.95
resolveMethod · 0.65
bodyMethod · 0.65
headersMethod · 0.65
requestMethod · 0.45
targetMethod · 0.45
methodMethod · 0.45
buildMethod · 0.45
reasonMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected