diff --git a/wpilibc/src/main/native/cpp/DataLogManager.cpp b/wpilibc/src/main/native/cpp/DataLogManager.cpp index bd5e50bc54..3352d4db8e 100644 --- a/wpilibc/src/main/native/cpp/DataLogManager.cpp +++ b/wpilibc/src/main/native/cpp/DataLogManager.cpp @@ -4,6 +4,8 @@ #include "frc/DataLogManager.h" +#include + #include #include #include @@ -129,6 +131,8 @@ void Thread::Main() { } auto size = entry.file_size(); if (fs::remove(entry.path(), ec)) { + FRC_ReportError(warn::Warning, "DataLogManager: Deleted {}", + entry.path().string()); freeSpace += size; if (freeSpace >= kFreeSpaceThreshold) { break; @@ -138,6 +142,13 @@ void Thread::Main() { entry.path().string()); } } + } else if (freeSpace < 2 * kFreeSpaceThreshold) { + FRC_ReportError( + warn::Warning, + "DataLogManager: Log storage device has {} MB of free space " + "remaining! Logs will get deleted below {} MB of free space. " + "Consider deleting logs off the storage device.", + freeSpace / 1000000, kFreeSpaceThreshold / 1000000); } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DataLogManager.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DataLogManager.java index 76f8f7cddb..5a15468374 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DataLogManager.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DataLogManager.java @@ -257,6 +257,7 @@ public final class DataLogManager { } long length = file.length(); if (file.delete()) { + DriverStation.reportWarning("DataLogManager: Deleted " + file.getName(), false); freeSpace += length; if (freeSpace >= kFreeSpaceThreshold) { break; @@ -266,6 +267,15 @@ public final class DataLogManager { } } } + } else if (freeSpace < 2 * kFreeSpaceThreshold) { + DriverStation.reportWarning( + "DataLogManager: Log storage device has " + + freeSpace / 1000000 + + " MB of free space remaining! Logs will get deleted below " + + kFreeSpaceThreshold / 1000000 + + " MB of free space." + + "Consider deleting logs off the storage device.", + false); } }