mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
Logging additions 2 (#55)
* Add overload to logger.error() for Throwable to print stack trace * Replaced all e.printStackTrace() with logger.error() * Log level dependent on dev or release
This commit is contained in:
@@ -20,6 +20,8 @@ package org.photonvision.common.util;
|
||||
import edu.wpi.first.wpiutil.RuntimeDetector;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public enum Platform {
|
||||
@@ -42,6 +44,8 @@ public enum Platform {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private static final Logger logger = new Logger(Platform.class, LogGroup.General);
|
||||
|
||||
public static final Platform CurrentPlatform = getCurrentPlatform();
|
||||
|
||||
public static boolean isWindows() {
|
||||
@@ -64,7 +68,7 @@ public enum Platform {
|
||||
try {
|
||||
shell.execute("id", null, true, "-u");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Failed to perform root check!", e);
|
||||
}
|
||||
|
||||
while (!shell.isOutputCompleted()) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
|
||||
public final class SerializationUtils {
|
||||
private static final Logger LOGGER = new Logger(SerializationUtils.class, LogGroup.General);
|
||||
private static final Logger logger = new Logger(SerializationUtils.class, LogGroup.General);
|
||||
|
||||
public static HashMap<String, Object> objectToHashMap(Object src) {
|
||||
var ret = new HashMap<String, Object>();
|
||||
@@ -37,8 +37,7 @@ public final class SerializationUtils {
|
||||
ret.put(field.getName(), ordinal.ordinal());
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
LOGGER.error("Could not serialize " + src.getClass().getSimpleName());
|
||||
e.printStackTrace();
|
||||
logger.error("Could not serialize " + src.getClass().getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FileUtils {
|
||||
p.waitFor();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Setting perms failed!", e);
|
||||
}
|
||||
} else {
|
||||
logger.info("Cannot set directory permissions on Windows!");
|
||||
|
||||
Reference in New Issue
Block a user