projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: DRY for logging-category from io.projectreactor
[demos/kafka/chat]
/
src
/
main
/
java
/
de
/
juplo
/
kafka
/
chat
/
backend
/
storage
/
files
/
FilesStorageStrategy.java
diff --git
a/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
b/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
index
cdb4f0d
..
7c1fef0
100644
(file)
--- a/
src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
+++ b/
src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
@@
-17,6
+17,7
@@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;
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;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
@@
-32,6
+33,9
@@
public class FilesStorageStrategy implements StorageStrategy
private final Path storagePath;
private final ShardingStrategy shardingStrategy;
private final ObjectMapper mapper;
private final Path storagePath;
private final ShardingStrategy shardingStrategy;
private final ObjectMapper mapper;
+ private final String loggingCategory = FilesStorageStrategy.class.getSimpleName();
+ private final Level loggingLevel;
+ private final boolean showOperatorLine;
@Override
@Override
@@
-49,7
+53,10
@@
public class FilesStorageStrategy implements StorageStrategy
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
return chatRoomInfoFlux
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
return chatRoomInfoFlux
- .log()
+ .log(
+ loggingCategory,
+ loggingLevel,
+ showOperatorLine)
.doFirst(() ->
{
try
.doFirst(() ->
{
try
@@
-100,7
+107,10
@@
public class FilesStorageStrategy implements StorageStrategy
JavaType type = mapper.getTypeFactory().constructType(ChatRoomInfoTo.class);
return Flux
.from(new JsonFilePublisher<ChatRoomInfoTo>(chatroomsPath(), mapper, type))
JavaType type = mapper.getTypeFactory().constructType(ChatRoomInfoTo.class);
return Flux
.from(new JsonFilePublisher<ChatRoomInfoTo>(chatroomsPath(), mapper, type))
- .log()
+ .log(
+ loggingCategory,
+ loggingLevel,
+ showOperatorLine)
.map(chatRoomInfoTo ->
{
UUID chatRoomId = chatRoomInfoTo.getId();
.map(chatRoomInfoTo ->
{
UUID chatRoomId = chatRoomInfoTo.getId();
@@
-136,7
+146,10
@@
public class FilesStorageStrategy implements StorageStrategy
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
return messageFlux
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
return messageFlux
- .log()
+ .log(
+ loggingCategory,
+ loggingLevel,
+ showOperatorLine)
.doFirst(() ->
{
try
.doFirst(() ->
{
try
@@
-187,7
+200,10
@@
public class FilesStorageStrategy implements StorageStrategy
JavaType type = mapper.getTypeFactory().constructType(MessageTo.class);
return Flux
.from(new JsonFilePublisher<MessageTo>(chatroomPath(chatRoomId), mapper, type))
JavaType type = mapper.getTypeFactory().constructType(MessageTo.class);
return Flux
.from(new JsonFilePublisher<MessageTo>(chatroomPath(chatRoomId), mapper, type))
- .log()
+ .log(
+ loggingCategory,
+ loggingLevel,
+ showOperatorLine)
.map(MessageTo::toMessage);
}
.map(MessageTo::toMessage);
}