Add changes list to info logging

This commit is contained in:
RatzzFatzz
2025-12-19 22:35:07 +01:00
parent 1bdd3874e7
commit 62b637c241
6 changed files with 21 additions and 9 deletions

View File

@@ -12,10 +12,12 @@ import me.tongfei.progressbar.ProgressBarStyle;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Slf4j @Slf4j
public abstract class AttributeUpdater { public abstract class AttributeUpdater {
@@ -88,12 +90,12 @@ public abstract class AttributeUpdater {
if (config.isSafeMode()) return; if (config.isSafeMode()) return;
try { try {
log.info("Committing changes [{}] to {}", changeLog(fileInfo), fileInfo.getFile().getPath());
fileProcessor.update(fileInfo); fileProcessor.update(fileInfo);
statistic.changeSuccessful(); statistic.changeSuccessful();
log.info("Commited {} to '{}'", fileInfo.getMatchedConfig().toStringShort(), fileInfo.getFile().getPath());
} catch (IOException | MkvToolNixException e) { } catch (IOException | MkvToolNixException e) {
statistic.changeFailed(); statistic.changeFailed();
log.warn("Couldn't commit {} to '{}'", fileInfo.getMatchedConfig().toStringShort(), fileInfo.getFile().getPath(), e); log.warn("Couldn't commit changes [{}] to {}", changeLog(fileInfo), fileInfo.getFile().getPath(), e);
} }
} else if (fileInfo.getChanges().isEmpty()) { } else if (fileInfo.getChanges().isEmpty()) {
statistic.unchanged(); statistic.unchanged();
@@ -102,6 +104,15 @@ public abstract class AttributeUpdater {
} }
} }
private String changeLog(FileInfo fileInfo) {
List<String> changes = new ArrayList<>();
if (fileInfo.getMatchedConfig() != null) changes.add("defaults " + fileInfo.getMatchedConfig().toStringShort());
if (!fileInfo.getChanges().getForcedTrack().isEmpty()) changes.add("forced tags");
if (!fileInfo.getChanges().getCommentaryTrack().isEmpty()) changes.add("commentary tags");
if (!fileInfo.getChanges().getHearingImpairedTrack().isEmpty()) changes.add("hearing impaired tags");
return String.join(", ", changes);
}
// should this be here? // should this be here?
// protected void writeLastExecutionDate() { // protected void writeLastExecutionDate() {
// if (config.isSafeMode()) { // if (config.isSafeMode()) {

View File

@@ -47,6 +47,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
matchedFiles.size(), files.size(), rootDir.getPath()); matchedFiles.size(), files.size(), rootDir.getPath());
} }
log.info("Found coherent match {} for {}", matchedConfig.toStringShort(), rootDir.getPath());
matchedFiles.forEach(fileInfo -> { matchedFiles.forEach(fileInfo -> {
attributeChangeProcessor.findForcedTracksAndApplyChanges(fileInfo, this.config.isOverwriteForced()); attributeChangeProcessor.findForcedTracksAndApplyChanges(fileInfo, this.config.isOverwriteForced());
attributeChangeProcessor.findCommentaryTracksAndApplyChanges(fileInfo); attributeChangeProcessor.findCommentaryTracksAndApplyChanges(fileInfo);
@@ -64,12 +65,12 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
}); });
if (config.isForceCoherent()) { if (config.isForceCoherent()) {
log.info("No coherent match found, aborting: {}", rootDir.getPath()); log.info("No coherent match found, skipping {}", rootDir.getPath());
statistic.increaseUnchangedBy(files.size()); statistic.increaseUnchangedBy(files.size());
return; return;
} }
log.info("No coherent match found, trying to find coherent match in child directories: {}", rootDir.getPath()); log.info("No coherent match found, attempting to find coherent match in child directories of {}", rootDir.getPath());
for (File dir: fileProcessor.loadDirectory(rootDir.getPath(), 1)) this.process(dir); for (File dir: fileProcessor.loadDirectory(rootDir.getPath(), 1)) this.process(dir);
} }
@@ -83,7 +84,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
fileInfo.setMatchedConfig(null); fileInfo.setMatchedConfig(null);
if (fileInfo.getTracks().isEmpty()) { if (fileInfo.getTracks().isEmpty()) {
log.warn("No attributes found for file {}", file); log.warn("No attributes found for {}", file);
statistic.unknownFailed(); statistic.unknownFailed();
break; break;
} }

View File

@@ -31,7 +31,7 @@ public class SingleFileAttributeUpdater extends AttributeUpdater {
FileInfo fileInfo = fileProcessor.readAttributes(file); FileInfo fileInfo = fileProcessor.readAttributes(file);
if (fileInfo.getTracks().isEmpty()) { if (fileInfo.getTracks().isEmpty()) {
log.warn("No attributes found for file {}", file); log.warn("No attributes found for {}", file);
statistic.unknownFailed(); statistic.unknownFailed();
return; return;
} }

View File

@@ -6,7 +6,7 @@ Configuration:
fileName: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/application.log fileName: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/application.log
filePattern: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz filePattern: ${sys:user.home}/.local/mkvaudiosubtitlechanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
PatternLayout: PatternLayout:
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable" Pattern: "%d{DEFAULT} | %-5level | %msg %n %throwable"
ThresholdFilter: ThresholdFilter:
level: debug level: debug
Policies: Policies:

View File

@@ -6,7 +6,7 @@ Configuration:
fileName: ${sys:user.home}/AppData/Local/MKVAudioSubtitleChanger/logs/application.log fileName: ${sys:user.home}/AppData/Local/MKVAudioSubtitleChanger/logs/application.log
filePattern: ${sys:user.home}/AppData/Local/MKVAudioSubtitleChanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz filePattern: ${sys:user.home}/AppData/Local/MKVAudioSubtitleChanger/logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
PatternLayout: PatternLayout:
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable" Pattern: "%d{DEFAULT} | %-5level | %msg %n %throwable"
ThresholdFilter: ThresholdFilter:
level: debug level: debug
Policies: Policies:

View File

@@ -6,7 +6,7 @@ Configuration:
fileName: logs/application.log fileName: logs/application.log
filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
PatternLayout: PatternLayout:
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable" Pattern: "%d{DEFAULT} | %-5level | %msg %n %throwable"
ThresholdFilter: ThresholdFilter:
level: debug level: debug
Policies: Policies: