Skip to content

Conversation

@jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Jul 7, 2025

Implements configurable log level functionality, allowing developers to control logging verbosity in the DevCycle Android SDK.

Changes

Core Implementation

  • DevCycleLogger.kt: Added log level filtering with minLogLevel property and setMinLogLevel() method

    • Added isLoggable() logic to filter messages based on minimum log level
    • Supports all Android log levels: VERBOSE, DEBUG, INFO, WARN, ERROR, and NO_LOGGING
    • Thread-safe implementation with @Volatile property
  • DevCycleOptions.kt: Added logLevel configuration option

    • New logLevel() builder method for setting log level in options
    • Integrates with existing options pattern
  • DevCycleClient.kt: Updated client initialization to respect log level configuration

    • Options logLevel takes precedence over builder logLevel
    • Logger only starts when log level is not NO_LOGGING
    • Fixed deprecated event logging option fallback logic

Testing

  • DevCycleLoggerTests.kt: Added 3 focused tests covering:
    • Log level filtering (DEBUG vs ERROR levels)
    • NO_LOGGING disables all output
    • setMinLogLevel() updates correctly

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds configurable log level support to the DevCycle Android SDK, allowing developers to filter log output based on a minimum level.

  • Implements minLogLevel and setMinLogLevel() in DevCycleLogger with thread-safe filtering logic.
  • Extends DevCycleOptions to include a nullable logLevel builder option.
  • Updates DevCycleClient initialization to determine an effective log level (options vs. builder) and start the logger accordingly.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
android-client-sdk/src/main/java/com/devcycle/sdk/android/util/DevCycleLogger.kt Added minLogLevel filtering and updated isLoggable implementation
android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DevCycleOptions.kt Added nullable logLevel property and builder method
android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DevCycleClient.kt Calculates effective log level, sets logger, and conditionally starts it
android-client-sdk/src/test/java/com/devcycle/sdk/android/util/DevCycleLoggerTests.kt New tests for log level filtering, NO_LOGGING behavior, and setter
Comments suppressed due to low confidence (3)

android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DevCycleClient.kt:635

  • There is no test covering the precedence and selection logic between options.logLevel and builder logLevel. Consider adding a unit test that sets both values and verifies that the more verbose (lower) level is chosen correctly.
            val effectiveLogLevel = listOfNotNull(options?.logLevel, logLevel).minByOrNull { it.value } ?: LogLevel.ERROR

android-client-sdk/src/main/java/com/devcycle/sdk/android/util/DevCycleLogger.kt:142

  • The KDoc for this method mentions filtering by tag, but the tag parameter is not used in the logic. Update the comment to reflect that tag-based filtering is currently unsupported or implement tag filtering if intended.
    protected open fun isLoggable(tag: String?, priority: Int): Boolean {

android-client-sdk/src/main/java/com/devcycle/sdk/android/api/DevCycleOptions.kt:16

  • [nitpick] The logLevel property is nullable, which may require consumers to understand fallback behavior. Consider making it non-null with a default (e.g., ERROR) or document the null fallback in the class KDoc for clearer API usage.
    val logLevel: LogLevel?

@cursor cursor bot force-pushed the cursor/update-logger-to-use-configured-log-level-6646 branch from f708f3d to a43313f Compare July 11, 2025 16:17
@jonathannorris jonathannorris merged commit 2ca30af into main Jul 11, 2025
5 checks passed
@jonathannorris jonathannorris deleted the cursor/update-logger-to-use-configured-log-level-6646 branch July 11, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants