feat: Introduced config-parameters for the `io.projectreactor`-logging
[demos/kafka/chat] / src / main / java / de / juplo / kafka / chat / backend / storage / files / FilesStorageStrategy.java
index cdb4f0d..aaa6159 100644 (file)
@@ -17,6 +17,7 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.UUID;
+import java.util.logging.Level;
 
 import static java.nio.file.StandardOpenOption.CREATE;
 import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
@@ -32,6 +33,8 @@ public class FilesStorageStrategy implements StorageStrategy
   private final Path storagePath;
   private final ShardingStrategy shardingStrategy;
   private final ObjectMapper mapper;
+  private final Level loggingLevel;
+  private final boolean showOperatorLine;
 
 
   @Override
@@ -49,7 +52,10 @@ public class FilesStorageStrategy implements StorageStrategy
               .createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
 
       return chatRoomInfoFlux
-          .log()
+          .log(
+              FilesStorageStrategy.class.getSimpleName(),
+              loggingLevel,
+              showOperatorLine)
           .doFirst(() ->
           {
             try
@@ -100,7 +106,10 @@ public class FilesStorageStrategy implements StorageStrategy
     JavaType type = mapper.getTypeFactory().constructType(ChatRoomInfoTo.class);
     return Flux
         .from(new JsonFilePublisher<ChatRoomInfoTo>(chatroomsPath(), mapper, type))
-        .log()
+        .log(
+            FilesStorageStrategy.class.getSimpleName(),
+            loggingLevel,
+            showOperatorLine)
         .map(chatRoomInfoTo ->
         {
           UUID chatRoomId = chatRoomInfoTo.getId();
@@ -136,7 +145,10 @@ public class FilesStorageStrategy implements StorageStrategy
               .createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
 
       return messageFlux
-          .log()
+          .log(
+              FilesStorageStrategy.class.getSimpleName(),
+              loggingLevel,
+              showOperatorLine)
           .doFirst(() ->
           {
             try
@@ -187,7 +199,10 @@ public class FilesStorageStrategy implements StorageStrategy
     JavaType type = mapper.getTypeFactory().constructType(MessageTo.class);
     return Flux
         .from(new JsonFilePublisher<MessageTo>(chatroomPath(chatRoomId), mapper, type))
-        .log()
+        .log(
+            FilesStorageStrategy.class.getSimpleName(),
+            loggingLevel,
+            showOperatorLine)
         .map(MessageTo::toMessage);
   }