Skip to content

Commit

Permalink
FEAT : CDE-195-creer-consumer-pour-generer-les-2-fichiers-de-log
Browse files Browse the repository at this point in the history
     - ajout d'un contrôle sur la création du répertoire temporaire
  • Loading branch information
EryneKL committed Oct 5, 2023
1 parent 2fe40c8 commit b5c7a3f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/fr/abes/logskbart/kafka/LogsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.sql.Date;
Expand Down Expand Up @@ -93,10 +94,15 @@ public void listenInfoKbart2KafkaAndErrorKbart2Kafka(ConsumerRecord<String, Stri
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss", Locale.FRANCE);
String date = format.format(time);

// Vérification du chemin et création si inexistant
String tempLog = "tempLog/";
Files.createDirectory(Paths.get(tempLog));
File chemin = new File("tempLog/");
if (!chemin.isDirectory()) {
Files.createDirectory(Paths.get(tempLog));
}
Path target = Path.of("tempLog\\" + date + "_" + source);

// Déplacement du fichier
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
log.info("Fichier de log transféré dans le dossier temporaire.");
}
Expand Down

0 comments on commit b5c7a3f

Please sign in to comment.