Skip to content

Commit

Permalink
Add usage reporting for loggers
Browse files Browse the repository at this point in the history
Fixes #6606
Fixes #6918
  • Loading branch information
sciencewhiz committed Nov 29, 2024
1 parent 5e1c6a8 commit b973231
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hal/src/generate/Instances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ kDashboard_LabVIEW = 6
kDashboard_AdvantageScope = 7
kDashboard_QFRCDashboard = 8
kDashboard_FRCWebComponents = 9
kDataLogLocation_Onboard = 1
kDataLogLocation_USB = 2
kLoggingFramework_Other = 1
kLoggingFramework_Epilogue = 2
kLoggingFramework_Monologue = 3
kLoggingFramework_AdvantageKit = 4
kLoggingFramework_DogLog = 5
2 changes: 2 additions & 0 deletions hal/src/generate/ResourceType.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ kResourceType_Redux_future5 = 113
kResourceType_RevSparkFlexCAN = 114
kResourceType_RevSparkFlexPWM = 115
kResourceType_BangBangController = 116
kResourceType_DataLogManager = 117
kResourceType_LoggingFramework = 118
18 changes: 18 additions & 0 deletions hal/src/generated/main/java/edu/wpi/first/hal/FRCNetComm.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions hal/src/generated/main/native/include/hal/FRCUsageReporting.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions hal/src/generated/main/native/include/hal/UsageReporting.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions wpilibc/src/main/native/cpp/DataLogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>

#include <fmt/chrono.h>
#include <hal/FRCUsageReporting.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/DataLog.h>
#include <wpi/DataLogBackgroundWriter.h>
Expand Down Expand Up @@ -78,13 +79,17 @@ static std::string MakeLogDir(std::string_view dir) {
(s.permissions() & fs::perms::others_write) != fs::perms::none) {
fs::create_directory("/u/logs", ec);
return "/u/logs";
HAL_Report(HALUsageReporting::kResourceType_DataLogManager,
HALUsageReporting::kDataLogLocation_USB);
}
if (RobotBase::GetRuntimeType() == kRoboRIO) {
FRC_ReportWarning(
"DataLogManager: Logging to RoboRIO 1 internal storage is "
"not recommended! Plug in a FAT32 formatted flash drive!");
}
fs::create_directory("/home/lvuser/logs", ec);
HAL_Report(HALUsageReporting::kResourceType_DataLogManager,
HALUsageReporting::kDataLogLocation_Onboard);
return "/home/lvuser/logs";
#else
std::string logDir = filesystem::GetOperatingDirectory() + "/logs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

package edu.wpi.first.wpilibj;

import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.util.FileLogger;
import edu.wpi.first.util.WPIUtilJNI;
Expand Down Expand Up @@ -244,6 +247,7 @@ private static String makeLogDir(String dir) {
if (!new File("/u/logs").mkdir()) {
// ignored
}
HAL.report(tResourceType.kResourceType_DataLogManager, tInstances.kDataLogLocation_USB);
return "/u/logs";
}
} catch (IOException ex) {
Expand All @@ -258,6 +262,7 @@ private static String makeLogDir(String dir) {
if (!new File("/home/lvuser/logs").mkdir()) {
// ignored
}
HAL.report(tResourceType.kResourceType_DataLogManager, tInstances.kDataLogLocation_Onboard);
return "/home/lvuser/logs";
}
String logDir = Filesystem.getOperatingDirectory().getAbsolutePath() + "/logs";
Expand Down

0 comments on commit b973231

Please sign in to comment.