mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
Update logging
This commit is contained in:
@@ -58,15 +58,16 @@ public class AttributeUpdaterKernel {
|
||||
}
|
||||
|
||||
private void process(File file, ProgressBar progressBar) {
|
||||
statistic.total();
|
||||
List<FileAttribute> attributes = processor.loadAttributes(file);
|
||||
FileInfoDto fileInfo = processor.filterAttributes(attributes);
|
||||
statistic.total();
|
||||
if (fileInfo.isChangeNecessary()) {
|
||||
statistic.shouldChange();
|
||||
if (!Config.getInstance().isSafeMode()) {
|
||||
try {
|
||||
processor.update(file, fileInfo);
|
||||
statistic.success();
|
||||
log.info("Updated {}", file.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
statistic.failedChanging();
|
||||
log.warn("File couldn't be updated: {}", file.getAbsoluteFile());
|
||||
|
||||
@@ -2,6 +2,7 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl;
|
||||
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.Config;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.*;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.util.LogUtils;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -60,6 +61,8 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
LaneType.valueOf(((String) attribute.get("type")).toUpperCase(Locale.ENGLISH))));
|
||||
}
|
||||
}
|
||||
|
||||
LogUtils.ifDebug(log, fileAttributes);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("File could not be found or loaded!");
|
||||
@@ -76,6 +79,7 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
|
||||
detectCurrentConfiguration(attributes, info, nonForcedTracks);
|
||||
detectDesiredConfiguration(info, nonForcedTracks);
|
||||
LogUtils.ifDebug(log, info);
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -117,7 +121,7 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
|
||||
@Override
|
||||
public void update(File file, FileInfoDto fileInfo) throws IOException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(format("\"%s\" ", Config.getInstance().getPathFor(MkvToolNix.MKV_PROP_EDIT)));
|
||||
sb.append(format("\"%s\" ", file.getAbsolutePath()));
|
||||
if (fileInfo.isAudioDifferent()) {
|
||||
@@ -139,6 +143,6 @@ public class MkvFileProcessor implements FileProcessor {
|
||||
}
|
||||
|
||||
InputStream inputstream = Runtime.getRuntime().exec(sb.toString()).getInputStream();
|
||||
log.debug(IOUtils.toString(new InputStreamReader(inputstream)));
|
||||
LogUtils.ifDebug(log, IOUtils.toString(new InputStreamReader(inputstream)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,17 @@ public class FileAttribute {
|
||||
this.forcedTrack = forcedTrack;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("[");
|
||||
sb.append("id=").append(id);
|
||||
sb.append(", language='").append(language).append('\'');
|
||||
sb.append(", trackName='").append(trackName).append('\'');
|
||||
sb.append(", defaultTrack=").append(defaultTrack);
|
||||
sb.append(", forcedTrack=").append(forcedTrack);
|
||||
sb.append(", type=").append(type);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,16 @@ public class FileInfoDto {
|
||||
public boolean areForcedTracksDifferent() {
|
||||
return desiredForcedSubtitleLanes.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("[");
|
||||
sb.append("defaultAudioLane=").append(defaultAudioLane);
|
||||
sb.append(", defaultSubtitleLane=").append(defaultSubtitleLane);
|
||||
sb.append(", desiredForcedSubtitleLanes=").append(desiredForcedSubtitleLanes);
|
||||
sb.append(", desiredAudioLane=").append(desiredAudioLane);
|
||||
sb.append(", desiredSubtitleLane=").append(desiredSubtitleLane);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package at.pcgamingfreaks.mkvaudiosubtitlechanger.util;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LogUtils {
|
||||
|
||||
public static <T> void ifDebug(Logger log, T object) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user