Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/src/main/java/dev/doglog/DogLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ public static void setOptions(@Nullable DogLogOptions newOptions) {
if (!oldOptions.equals(newOptions)) {
System.out.println("[DogLog] Options changed: " + newOptions);
logger.setOptions(newOptions);
if (oldOptions.useLogThread() != newOptions.useLogThread()) {
// Create the new logger before we close the old one, to avoid race condition
var oldLogger = logger;
logger = LogWriterHighLevel.create(newOptions);

try {
oldLogger.close();
} catch (Exception e) {
System.err.println("[DogLog] Error closing old LogWriter instance:");
e.printStackTrace();
}
}
tunable.setOptions(newOptions);
}

Expand Down
110 changes: 8 additions & 102 deletions lib/src/main/java/dev/doglog/DogLogOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@ public record DogLogOptions(
boolean logExtras,
/** Whether console output should be saved to the log file. */
boolean captureConsole,
/** The maximum size of the log entry queue to use. */
int logEntryQueueCapacity,
/**
* A function that returns whether tunable values from NetworkTables should be used. Best
* practice is to have this disabled when you are at competitions, to make robot behavior more
* deterministic. The default behavior is to only use tunable values from NetworkTables when not
* connected to the FMS on a competition field.
*/
BooleanSupplier ntTunables,
/**
* Whether to use a separate thread to handle log entries. This setting defaults to true.
* Turning off the log thread may reduce the memory usage of logging, but could cause increased
* CPU load.
*/
boolean useLogThread) {
BooleanSupplier ntTunables) {
private static boolean isNotOnFms() {
return !DriverStation.isFMSAttached();
}
Expand All @@ -59,8 +51,7 @@ private static boolean isNotOnFms() {
*/
public DogLogOptions() {
// Default options
this(
DogLogOptions::isNotOnFms, false, false, true, true, 1000, DogLogOptions::isNotOnFms, true);
this(DogLogOptions::isNotOnFms, false, false, true, true, DogLogOptions::isNotOnFms);
}

/**
Expand Down Expand Up @@ -95,14 +86,7 @@ public DogLogOptions withNtPublish(boolean ntPublish) {
*/
public DogLogOptions withNtPublish(BooleanSupplier ntPublish) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
ntPublish, captureNt, captureDs, logExtras, captureConsole, ntTunables);
}

/**
Expand All @@ -118,14 +102,7 @@ public DogLogOptions withNtPublish(BooleanSupplier ntPublish) {
*/
public DogLogOptions withCaptureNt(boolean captureNt) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
ntPublish, captureNt, captureDs, logExtras, captureConsole, ntTunables);
}

/**
Expand All @@ -141,14 +118,7 @@ public DogLogOptions withCaptureNt(boolean captureNt) {
*/
public DogLogOptions withCaptureDs(boolean captureDs) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
ntPublish, captureNt, captureDs, logExtras, captureConsole, ntTunables);
}

/**
Expand All @@ -165,38 +135,7 @@ public DogLogOptions withCaptureDs(boolean captureDs) {
*/
public DogLogOptions withLogExtras(boolean logExtras) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
}

/**
* Create a new options object, inheriting the configuration from this one, with {@link
* DogLogOptions#logEntryQueueCapacity} set to the provided value.
*
* <p>Example:
*
* <pre>DogLog.setOptions(new DogLogOptions().withLogEntryQueueCapacity(1000));</pre>
*
* @param logEntryQueueCapacity The size of the log message queue to use.
* @return A new options object with {@link DogLogOptions#logEntryQueueCapacity} set to the
* provided value.
*/
public DogLogOptions withLogEntryQueueCapacity(int logEntryQueueCapacity) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
ntPublish, captureNt, captureDs, logExtras, captureConsole, ntTunables);
}

/**
Expand All @@ -213,14 +152,7 @@ public DogLogOptions withLogEntryQueueCapacity(int logEntryQueueCapacity) {
*/
public DogLogOptions withCaptureConsole(boolean captureConsole) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
ntPublish, captureNt, captureDs, logExtras, captureConsole, ntTunables);
}

/**
Expand Down Expand Up @@ -254,32 +186,6 @@ public DogLogOptions withNtTunables(boolean ntTunables) {
*/
public DogLogOptions withNtTunables(BooleanSupplier ntTunables) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
}

/**
* Create a new options object, inheriting the configuration from this one, with {@link
* DogLogOptions#useLogThread} set to the provided value.
*
* @param useLogThread Whether to use a separate thread to handle log entries.
* @return A new options object with {@link DogLogOptions#useLogThread} set to the provided value.
*/
public DogLogOptions withUseLogThread(boolean useLogThread) {
return new DogLogOptions(
ntPublish,
captureNt,
captureDs,
logExtras,
captureConsole,
logEntryQueueCapacity,
ntTunables,
useLogThread);
ntPublish, captureNt, captureDs, logExtras, captureConsole, ntTunables);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.doglog.internal.log_thread;
package dev.doglog.internal;

import edu.wpi.first.util.struct.Struct;
import edu.wpi.first.util.struct.StructGenerator;
Expand Down
103 changes: 0 additions & 103 deletions lib/src/main/java/dev/doglog/internal/log_thread/LogThread.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading