|
|
@ -43,7 +43,7 @@ public class Slf4jLoggerTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void useFeignLoggerByDefault() throws Exception { |
|
|
|
public void useFeignLoggerByDefault() throws Exception { |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.expectMessages("DEBUG feign.Logger - [someMethod] This is my message\n"); |
|
|
|
slf4j.expectMessages("DEBUG feign.Logger - [someMethod] This is my message" + System.lineSeparator()); |
|
|
|
|
|
|
|
|
|
|
|
logger = new Slf4jLogger(); |
|
|
|
logger = new Slf4jLogger(); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
@ -52,7 +52,7 @@ public class Slf4jLoggerTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void useLoggerByNameIfRequested() throws Exception { |
|
|
|
public void useLoggerByNameIfRequested() throws Exception { |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.expectMessages("DEBUG named.logger - [someMethod] This is my message\n"); |
|
|
|
slf4j.expectMessages("DEBUG named.logger - [someMethod] This is my message" + System.lineSeparator()); |
|
|
|
|
|
|
|
|
|
|
|
logger = new Slf4jLogger("named.logger"); |
|
|
|
logger = new Slf4jLogger("named.logger"); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
@ -61,7 +61,7 @@ public class Slf4jLoggerTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void useLoggerByClassIfRequested() throws Exception { |
|
|
|
public void useLoggerByClassIfRequested() throws Exception { |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.expectMessages("DEBUG feign.Feign - [someMethod] This is my message\n"); |
|
|
|
slf4j.expectMessages("DEBUG feign.Feign - [someMethod] This is my message" + System.lineSeparator()); |
|
|
|
|
|
|
|
|
|
|
|
logger = new Slf4jLogger(Feign.class); |
|
|
|
logger = new Slf4jLogger(Feign.class); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
@ -70,7 +70,7 @@ public class Slf4jLoggerTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void useSpecifiedLoggerIfRequested() throws Exception { |
|
|
|
public void useSpecifiedLoggerIfRequested() throws Exception { |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.expectMessages("DEBUG specified.logger - [someMethod] This is my message\n"); |
|
|
|
slf4j.expectMessages("DEBUG specified.logger - [someMethod] This is my message" + System.lineSeparator()); |
|
|
|
|
|
|
|
|
|
|
|
logger = new Slf4jLogger(LoggerFactory.getLogger("specified.logger")); |
|
|
|
logger = new Slf4jLogger(LoggerFactory.getLogger("specified.logger")); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
|
logger.log(CONFIG_KEY, "This is my message"); |
|
|
@ -89,10 +89,12 @@ public class Slf4jLoggerTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void logRequestsAndResponses() throws Exception { |
|
|
|
public void logRequestsAndResponses() throws Exception { |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.logLevel("debug"); |
|
|
|
slf4j.expectMessages("DEBUG feign.Logger - [someMethod] A message with 2 formatting tokens.\n" + |
|
|
|
slf4j.expectMessages("DEBUG feign.Logger - [someMethod] A message with 2 formatting tokens." |
|
|
|
"DEBUG feign.Logger - [someMethod] ---> GET http://api.example.com HTTP/1.1\n" |
|
|
|
+ System.lineSeparator() + |
|
|
|
+ |
|
|
|
"DEBUG feign.Logger - [someMethod] ---> GET http://api.example.com HTTP/1.1" |
|
|
|
"DEBUG feign.Logger - [someMethod] <--- HTTP/1.1 200 OK (273ms)\n"); |
|
|
|
+ System.lineSeparator() + |
|
|
|
|
|
|
|
"DEBUG feign.Logger - [someMethod] <--- HTTP/1.1 200 OK (273ms)" |
|
|
|
|
|
|
|
+ System.lineSeparator()); |
|
|
|
|
|
|
|
|
|
|
|
logger = new Slf4jLogger(); |
|
|
|
logger = new Slf4jLogger(); |
|
|
|
logger.log(CONFIG_KEY, "A message with %d formatting %s.", 2, "tokens"); |
|
|
|
logger.log(CONFIG_KEY, "A message with %d formatting %s.", 2, "tokens"); |
|
|
|