Skip to content

Commit

Permalink
tweak controller and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rkamradt committed May 16, 2020
1 parent e126d76 commit 9c1c926
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ Flux<Inserts.Articles> getFromMongo(final Instant from, final Instant to, final
long actualLimit = limit == null || limit == 0 || limit > MAX_LIMIT
? MAX_LIMIT
: limit;
log.info("returning news with " + actualLimit);
return newsReactiveRepository
.findAll()
.flatMap(r -> Flux.fromIterable(r.getArticles()))
.filter(r -> filterByDate(r, from, to))
.doFinally((type) -> log.info("returned news with limit " + actualLimit + " type " + type))
.limitRequest(actualLimit);
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>

<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>10000</queueSize>
<neverBlock>true</neverBlock>
<appender-ref ref="CONSOLE" />
</appender>

<root level="INFO">
<appender-ref ref="ASYNC" />
</root>
</configuration>

0 comments on commit 9c1c926

Please sign in to comment.