Skip to content

Commit dc0e3ff

Browse files
Merge pull request #220 from Spikes-2212-Programming-Guild/SpikesLogger
added logWithTimestamp
2 parents d8df600 + 3583b7b commit dc0e3ff

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/com/spikes2212/dashboard/SpikesLogger.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.spikes2212.dashboard;
22

33
import edu.wpi.first.networktables.NetworkTable;
4+
import java.time.LocalTime;
45
import edu.wpi.first.wpilibj2.command.Command;
56
import edu.wpi.first.wpilibj2.command.InstantCommand;
67

@@ -49,6 +50,15 @@ public <T> void log(T output) {
4950
putString(key, output == null ? "null" : output.toString());
5051
}
5152

53+
/**
54+
* Logs the provided output with a timestamp to the NetworkTables and the SpikesLogger app.
55+
*
56+
* @param output the data to be logged
57+
*/
58+
public <T> void logWithTimestamp(T output) {
59+
log(LocalTime.now() + ": " + output);
60+
}
61+
5262
/**
5363
* Returns a command that logs the provided output to the NetworkTables and the SpikesLogger app.
5464
*
@@ -58,4 +68,14 @@ public <T> void log(T output) {
5868
public <T> Command logCommand(T output) {
5969
return new InstantCommand(() -> log(output));
6070
}
71+
72+
/**
73+
* Returns a command that logs the provided output with a timestamp to the NetworkTables and the SpikesLogger app.
74+
*
75+
* @param output the data to be logged
76+
* @return a command that logs the output
77+
*/
78+
public <T> Command logWithTimestampCommand(T output) {
79+
return new InstantCommand(() -> logWithTimestamp(output));
80+
}
6181
}

0 commit comments

Comments
 (0)