diff --git a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java index ab4d5a662..9d659956e 100644 --- a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java +++ b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java @@ -22,6 +22,7 @@ public final class DiskBufferingConfiguration { private final long maxFileAgeForWriteMillis; private final long minFileAgeForReadMillis; private final long maxFileAgeForReadMillis; + private final boolean enableDebugMode; private DiskBufferingConfiguration(Builder builder) { enabled = builder.enabled; @@ -30,6 +31,7 @@ private DiskBufferingConfiguration(Builder builder) { maxFileAgeForWriteMillis = builder.maxFileAgeForWriteMillis; minFileAgeForReadMillis = builder.minFileAgeForReadMillis; maxFileAgeForReadMillis = builder.maxFileAgeForReadMillis; + enableDebugMode = builder.enableDebugMode; } public static Builder builder() { @@ -70,12 +72,30 @@ public static final class Builder { private long maxFileAgeForWriteMillis = TimeUnit.SECONDS.toMillis(30); private long minFileAgeForReadMillis = TimeUnit.SECONDS.toMillis(33); private long maxFileAgeForReadMillis = TimeUnit.HOURS.toMillis(18); + private boolean enableDebugMode = false; private ExportScheduleHandler exportScheduleHandler = DefaultExportScheduleHandler.create(); + /** Sets the debug mode for disk buffering, enabling additional logging. */ + public Builder setDebugMode(boolean enableDebugMode) { + this.enableDebugMode = enableDebugMode; + Logger.getLogger(DiskBufferingConfiguration.class.getName()) + .log( + Level.INFO, + "Disk buffering has been " + + (enabled ? "enabled." : "disabled.") + + (enableDebugMode ? " Debug mode is active." : "")); + return this; + } + /** Enables or disables disk buffering. */ public Builder setEnabled(boolean enabled) { this.enabled = enabled; + if (enableDebugMode) { + Logger.getLogger(DiskBufferingConfiguration.class.getName()) + .log(Level.INFO, "Debug log message here"); + } + return this; }