feign.Logger.Level Java Examples

The following examples show how to use feign.Logger.Level. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimulatedDeviceFactory.java    From hawkbit-examples with Eclipse Public License 1.0 6 votes vote down vote up
private AbstractSimulatedDevice createDdiDevice(final String id, final String tenant, final int pollDelaySec,
        final URL baseEndpoint, final String gatewayToken) {

    final ObjectMapper mapper = new ObjectMapper()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .registerModule(new Jackson2HalModule());

    final RootControllerResourceClient controllerResource = Feign.builder()
            .requestInterceptor(new GatewayTokenInterceptor(gatewayToken))
            .contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).logLevel(Level.HEADERS)
            .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper))).encoder(new JacksonEncoder())
            .logger(new Slf4jLogger()).decode404()
            .target(RootControllerResourceClient.class, baseEndpoint.toString());

    return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater, gatewayToken);
}
 
Example #2
Source File: RealRequestBenchmarks.java    From feign with Apache License 2.0 6 votes vote down vote up
@Setup
public void setup() {

  server = HttpServer.newServer(SERVER_PORT)
      .start((request, response) -> null);
  client = new OkHttpClient();
  client.retryOnConnectionFailure();
  okFeign = Feign.builder()
      .client(new feign.okhttp.OkHttpClient(client))
      .logLevel(Level.NONE)
      .logger(new Logger.ErrorLogger())
      .retryer(new Retryer.Default())
      .target(FeignTestInterface.class, "http://localhost:" + SERVER_PORT);
  queryRequest = new Request.Builder()
      .url("http://localhost:" + SERVER_PORT + "/?Action=GetUser&Version=2010-05-08&limit=1")
      .build();
}
 
Example #3
Source File: ReactiveFeignIntegrationTest.java    From feign with Apache License 2.0 6 votes vote down vote up
@Test
public void testRxJavaTarget() throws Exception {
  this.webServer.enqueue(new MockResponse().setBody("1.0"));
  this.webServer.enqueue(new MockResponse().setBody("{ \"username\": \"test\" }"));

  TestReactiveXService service = RxJavaFeign.builder()
      .encoder(new JacksonEncoder())
      .decoder(new JacksonDecoder())
      .logger(new ConsoleLogger())
      .logLevel(Level.FULL)
      .target(TestReactiveXService.class, this.getServerUrl());
  assertThat(service).isNotNull();

  StepVerifier.create(service.version())
      .expectNext("1.0")
      .expectComplete()
      .verify();
  assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/version");

  /* test encoding and decoding */
  StepVerifier.create(service.user("test"))
      .assertNext(user -> assertThat(user).hasFieldOrPropertyWithValue("username", "test"))
      .expectComplete()
      .verify();
  assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/users/test");
}
 
Example #4
Source File: LoggerTest.java    From feign with Apache License 2.0 6 votes vote down vote up
@Parameters
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
      {Level.NONE, Collections.emptyList()},
      {Level.BASIC, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://sna%fu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: sna%fu.abc \\([0-9]+ms\\)")},
      {Level.HEADERS, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://sna%fu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: sna%fu.abc \\([0-9]+ms\\)")},
      {Level.FULL, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://sna%fu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ",
          "\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"\\}",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: sna%fu.abc \\([0-9]+ms\\)",
          "(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: sna%fu.abc.*",
          "\\[SendsStuff#login\\] <--- END ERROR")}
  });
}
 
Example #5
Source File: LoggerTest.java    From feign with Apache License 2.0 6 votes vote down vote up
@Parameters
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
      {Level.NONE, Collections.emptyList()},
      {Level.BASIC, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)")},
      {Level.HEADERS, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)")},
      {Level.FULL, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ",
          "\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"\\}",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)",
          "(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: robofu.abc.*",
          "\\[SendsStuff#login\\] <--- END ERROR")}
  });
}
 
Example #6
Source File: LoggerTest.java    From feign with Apache License 2.0 6 votes vote down vote up
@Parameters
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
      {Level.NONE, Collections.emptyList()},
      {Level.BASIC, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- ERROR SocketTimeoutException: Read timed out \\([0-9]+ms\\)")},
      {Level.HEADERS, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- ERROR SocketTimeoutException: Read timed out \\([0-9]+ms\\)")},
      {Level.FULL, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ",
          "\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"\\}",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- ERROR SocketTimeoutException: Read timed out \\([0-9]+ms\\)",
          "(?s)\\[SendsStuff#login\\] java.net.SocketTimeoutException: Read timed out.*",
          "\\[SendsStuff#login\\] <--- END ERROR")}
  });
}
 
Example #7
Source File: LoggerTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Parameters
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
      {Level.BASIC, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- HTTP/1.1 200 \\([0-9]+ms\\)")},
  });
}
 
Example #8
Source File: Denominator.java    From denominator with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a log configuration module or null if none is needed.
 */
static Object logModule(boolean quiet, boolean verbose) {
  checkArgument(!(quiet && verbose), "quiet and verbose flags cannot be used at the same time!");
  Logger.Level logLevel;
  if (quiet) {
    return null;
  } else if (verbose) {
    logLevel = Logger.Level.FULL;
  } else {
    logLevel = Logger.Level.BASIC;
  }
  return new LogModule(logLevel);
}
 
Example #9
Source File: LoggerTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Parameters
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
      {Level.NONE, Collections.emptyList()},
      {Level.BASIC, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)",
          "\\[SendsStuff#login\\] ---> RETRYING",
          "\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)")}
  });
}
 
Example #10
Source File: OneSignal.java    From OneSignal-Java-SDK with Apache License 2.0 5 votes vote down vote up
private static OneSignalComms oneSignal() {
    JacksonDecoder decoder = new JacksonDecoder(OBJECT_MAPPER);
    return Feign.builder()
            .encoder(new JacksonEncoder(OBJECT_MAPPER))
            .decoder(decoder)
            .decode404()
            .errorDecoder(new OneSignalErrorDecoder(decoder))
            .logger(new Slf4jLogger())
            .logLevel(Level.FULL)
            .target(OneSignalComms.class, "https://onesignal.com/api/v1");
}
 
Example #11
Source File: LoggerTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Parameters
public static Iterable<Object[]> data() {
  return Arrays.asList(new Object[][] {
      {Level.NONE, Collections.emptyList()},
      {Level.BASIC, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] <--- HTTP/1.1 200 OK \\([0-9]+ms\\)")},
      {Level.HEADERS, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- HTTP/1.1 200 OK \\([0-9]+ms\\)",
          "\\[SendsStuff#login\\] content-length: 3",
          "\\[SendsStuff#login\\] <--- END HTTP \\(3-byte body\\)")},
      {Level.FULL, Arrays.asList(
          "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1",
          "\\[SendsStuff#login\\] Content-Length: 80",
          "\\[SendsStuff#login\\] Content-Type: application/json",
          "\\[SendsStuff#login\\] ",
          "\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"\\}",
          "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
          "\\[SendsStuff#login\\] <--- HTTP/1.1 200 OK \\([0-9]+ms\\)",
          "\\[SendsStuff#login\\] content-length: 3",
          "\\[SendsStuff#login\\] ",
          "\\[SendsStuff#login\\] foo",
          "\\[SendsStuff#login\\] <--- END HTTP \\(3-byte body\\)")}
  });
}
 
Example #12
Source File: AsyncResponseHandler.java    From feign with Apache License 2.0 5 votes vote down vote up
AsyncResponseHandler(Level logLevel, Logger logger, Decoder decoder, ErrorDecoder errorDecoder,
    boolean decode404, boolean closeAfterDecode) {
  super();
  this.logLevel = logLevel;
  this.logger = logger;
  this.decoder = decoder;
  this.errorDecoder = errorDecoder;
  this.decode404 = decode404;
  this.closeAfterDecode = closeAfterDecode;
}
 
Example #13
Source File: ReactiveFeignIntegrationTest.java    From feign with Apache License 2.0 5 votes vote down vote up
@Test
public void testReactorTargetFull() throws Exception {
  this.webServer.enqueue(new MockResponse().setBody("1.0"));
  this.webServer.enqueue(new MockResponse().setBody("{ \"username\": \"test\" }"));

  TestReactorService service = ReactorFeign.builder()
      .encoder(new JacksonEncoder())
      .decoder(new JacksonDecoder())
      .logger(new ConsoleLogger())
      .decode404()
      .options(new Options())
      .logLevel(Level.FULL)
      .target(TestReactorService.class, this.getServerUrl());
  assertThat(service).isNotNull();

  StepVerifier.create(service.version())
      .expectNext("1.0")
      .expectComplete()
      .verify();
  assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/version");


  /* test encoding and decoding */
  StepVerifier.create(service.user("test"))
      .assertNext(user -> assertThat(user).hasFieldOrPropertyWithValue("username", "test"))
      .expectComplete()
      .verify();
  assertThat(webServer.takeRequest().getPath()).isEqualToIgnoringCase("/users/test");

}
 
Example #14
Source File: GameClientResolver.java    From codenjoy with GNU General Public License v3.0 5 votes vote down vote up
private GameServerClient buildGameServerClient(String server) {
    return Feign.builder()
            .client(new OkHttpClient())
            .encoder(new JacksonEncoder())
            .decoder(new JacksonDecoder())
            .errorDecoder(new ClientErrorDecoder())
            .logger(new Slf4jLogger(GameServerClient.class))
            .logLevel(Level.BASIC)
            .requestInterceptor(new BasicAuthRequestInterceptor(gameProperties.getBasicAuthUser(),
                    Hash.md5(gameProperties.getBasicAuthPassword())))
            .target(GameServerClient.class, gameProperties.getSchema() + "://" + server);
}
 
Example #15
Source File: LoggerTest.java    From feign with Apache License 2.0 4 votes vote down vote up
public ReasonPhraseOptional(Level logLevel, List<String> expectedMessages) {
  this.logLevel = logLevel;
  logger.expectMessages(expectedMessages);
}
 
Example #16
Source File: LoggerTest.java    From feign with Apache License 2.0 4 votes vote down vote up
public ReadTimeoutEmitsTest(Level logLevel, List<String> expectedMessages) {
  this.logLevel = logLevel;
  logger.expectMessages(expectedMessages);
}
 
Example #17
Source File: LoggerTest.java    From feign with Apache License 2.0 4 votes vote down vote up
public LogLevelEmitsTest(Level logLevel, List<String> expectedMessages) {
  this.logLevel = logLevel;
  logger.expectMessages(expectedMessages);
}
 
Example #18
Source File: LoggerTest.java    From feign with Apache License 2.0 4 votes vote down vote up
public UnknownHostEmitsTest(Level logLevel, List<String> expectedMessages) {
  this.logLevel = logLevel;
  logger.expectMessages(expectedMessages);
}
 
Example #19
Source File: LoggerTest.java    From feign with Apache License 2.0 4 votes vote down vote up
public FormatCharacterTest(Level logLevel, List<String> expectedMessages) {
  this.logLevel = logLevel;
  logger.expectMessages(expectedMessages);
}
 
Example #20
Source File: Capability.java    From feign with Apache License 2.0 4 votes vote down vote up
default Level enrich(Level level) {
  return level;
}
 
Example #21
Source File: LoggerTest.java    From feign with Apache License 2.0 4 votes vote down vote up
public RetryEmitsTest(Level logLevel, List<String> expectedMessages) {
  this.logLevel = logLevel;
  logger.expectMessages(expectedMessages);
}
 
Example #22
Source File: Denominator.java    From denominator with Apache License 2.0 4 votes vote down vote up
LogModule(Level logLevel) {
  this.logLevel = logLevel;
}
 
Example #23
Source File: Denominator.java    From denominator with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
Logger.Level level() {
  return logLevel;
}