mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Add changes list to info logging
This commit is contained in:
@@ -12,10 +12,12 @@ import me.tongfei.progressbar.ProgressBarStyle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public abstract class AttributeUpdater {
|
||||
@@ -88,12 +90,12 @@ public abstract class AttributeUpdater {
|
||||
if (config.isSafeMode()) return;
|
||||
|
||||
try {
|
||||
log.info("Committing changes [{}] to {}", changeLog(fileInfo), fileInfo.getFile().getPath());
|
||||
fileProcessor.update(fileInfo);
|
||||
statistic.changeSuccessful();
|
||||
log.info("Commited {} to '{}'", fileInfo.getMatchedConfig().toStringShort(), fileInfo.getFile().getPath());
|
||||
} catch (IOException | MkvToolNixException e) {
|
||||
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()) {
|
||||
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?
|
||||
// protected void writeLastExecutionDate() {
|
||||
// if (config.isSafeMode()) {
|
||||
|
||||
@@ -47,6 +47,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
|
||||
matchedFiles.size(), files.size(), rootDir.getPath());
|
||||
}
|
||||
|
||||
log.info("Found coherent match {} for {}", matchedConfig.toStringShort(), rootDir.getPath());
|
||||
matchedFiles.forEach(fileInfo -> {
|
||||
attributeChangeProcessor.findForcedTracksAndApplyChanges(fileInfo, this.config.isOverwriteForced());
|
||||
attributeChangeProcessor.findCommentaryTracksAndApplyChanges(fileInfo);
|
||||
@@ -64,12 +65,12 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
|
||||
});
|
||||
|
||||
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());
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
|
||||
fileInfo.setMatchedConfig(null);
|
||||
|
||||
if (fileInfo.getTracks().isEmpty()) {
|
||||
log.warn("No attributes found for file {}", file);
|
||||
log.warn("No attributes found for {}", file);
|
||||
statistic.unknownFailed();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SingleFileAttributeUpdater extends AttributeUpdater {
|
||||
FileInfo fileInfo = fileProcessor.readAttributes(file);
|
||||
|
||||
if (fileInfo.getTracks().isEmpty()) {
|
||||
log.warn("No attributes found for file {}", file);
|
||||
log.warn("No attributes found for {}", file);
|
||||
statistic.unknownFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ Configuration:
|
||||
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
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: debug
|
||||
Policies:
|
||||
|
||||
@@ -6,7 +6,7 @@ Configuration:
|
||||
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
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: debug
|
||||
Policies:
|
||||
|
||||
@@ -6,7 +6,7 @@ Configuration:
|
||||
fileName: logs/application.log
|
||||
filePattern: logs/archive/application-%d{yyyy-MM-dd}-%i.log.gz
|
||||
PatternLayout:
|
||||
Pattern: "%d{DEFAULT} | %-5level | %thread | %C{1} | %msg %n %throwable"
|
||||
Pattern: "%d{DEFAULT} | %-5level | %msg %n %throwable"
|
||||
ThresholdFilter:
|
||||
level: debug
|
||||
Policies:
|
||||
|
||||
Reference in New Issue
Block a user