Improved logging for when xattr is not supported

This commit is contained in:
Reinhard Pointner 2017-03-31 01:25:53 +08:00
parent 3db5e7f7f5
commit 1467003565
2 changed files with 13 additions and 5 deletions

View File

@ -96,6 +96,15 @@ public final class Logging {
};
}
public static Supplier<String> cause(String m, Throwable t) {
return () -> {
StringBuilder s = new StringBuilder(m).append(": ");
s.append(t.getClass().getSimpleName()).append(": ");
s.append(t.getMessage());
return s.toString();
};
}
public static Supplier<String> cause(Throwable t) {
return () -> {
StringBuilder s = new StringBuilder();

View File

@ -2,7 +2,6 @@ package net.filebot.media;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.util.ExceptionUtilities.*;
import java.io.File;
import java.util.Locale;
@ -70,7 +69,7 @@ public class XattrMetaInfo {
try {
return cache.computeIfAbsent(file, element -> compute.apply(xattr(file)));
} catch (Throwable e) {
debug.warning("Failed to read xattr: " + getRootCauseMessage(e));
debug.warning(cause("Failed to read xattr", e));
}
return null;
}
@ -95,7 +94,7 @@ public class XattrMetaInfo {
xattr.get().setCreationDate(t);
}
} catch (Throwable e) {
debug.warning("Failed to set creation date: " + getRootCauseMessage(e));
debug.warning(cause("Failed to set creation date", e));
}
}
@ -117,7 +116,7 @@ public class XattrMetaInfo {
}
}
} catch (Throwable e) {
debug.warning("Failed to set xattr: " + getRootCauseMessage(e));
debug.warning(cause("Failed to set xattr", e));
}
}
@ -130,7 +129,7 @@ public class XattrMetaInfo {
try {
xattr(file).clear();
} catch (Throwable e) {
debug.warning("Failed to clear xattr: " + getRootCauseMessage(e));
debug.warning(cause("Failed to clear xattr", e));
}
}
}