-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Debug Logging #568
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4f1f88c
Add debug config
123mpozzi d54fa8a
first version
123mpozzi e35a0fe
moving to static class
123mpozzi 2d78196
add module on android
123mpozzi b91464f
Refactoring
123mpozzi e0ff572
Add docs
123mpozzi 9454d91
Add newline
123mpozzi f5b48c1
Add entry about debug logging getter and setter
123mpozzi e83380d
Rephrase in React-Native terms instead of native
123mpozzi a2d6bb1
Add missing class name
123mpozzi 10b027f
Shortify branch with ternary
123mpozzi 6ccf48a
Rename setter
123mpozzi d1b0ed2
Rename setter
123mpozzi 0b63086
Merge branch 'development' into feature/introduce-debugconfig
rolandkakonyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
android/src/main/java/com/bitmovin/player/reactnative/DebugModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bitmovin.player.reactnative | ||
|
||
import com.bitmovin.player.api.DebugConfig | ||
import com.facebook.react.bridge.* | ||
import com.facebook.react.module.annotations.ReactModule | ||
|
||
private const val MODULE_NAME = "DebugModule" | ||
|
||
@ReactModule(name = MODULE_NAME) | ||
class DebugModule(context: ReactApplicationContext) : BitmovinBaseModule(context) { | ||
override fun getName() = MODULE_NAME | ||
|
||
/** | ||
* Enable/disable verbose logging for the console logger. | ||
* @param enabled Whether to set verbose logging as enabled or disabled. | ||
*/ | ||
@ReactMethod | ||
fun setDebugLoggingEnabled(enabled: Boolean, promise: Promise) { | ||
promise.unit.resolveOnUiThread { | ||
DebugConfig.isLoggingEnabled = enabled | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface RCT_EXTERN_REMAP_MODULE(DebugModule, DebugModule, NSObject) | ||
|
||
RCT_EXTERN_METHOD(setDebugLoggingEnabled:(nonnull BOOL)enabled) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import BitmovinPlayer | ||
|
||
@objc(DebugModule) | ||
public class DebugModule: NSObject, RCTBridgeModule { | ||
// swiftlint:disable:next implicitly_unwrapped_optional | ||
@objc public var bridge: RCTBridge! | ||
|
||
// swiftlint:disable:next implicitly_unwrapped_optional | ||
public static func moduleName() -> String! { | ||
"DebugModule" | ||
} | ||
|
||
/// Module requires main thread initialization. | ||
public static func requiresMainQueueSetup() -> Bool { | ||
true | ||
} | ||
|
||
// swiftlint:disable:next implicitly_unwrapped_optional | ||
public var methodQueue: DispatchQueue! { | ||
bridge.uiManager.methodQueue | ||
} | ||
} | ||
|
||
extension DebugModule { | ||
/// Enable/disable verbose logging for the console logger. | ||
/// - Parameter enabled: Whether to set verbose logging as enabled or disabled. | ||
@objc(setDebugLoggingEnabled:) | ||
func setDebugLoggingEnabled(enabled: Bool) { | ||
bridge.uiManager.addUIBlock { [weak self] _, _ in | ||
DebugConfig.logging.logger?.level = enabled ? .verbose : .warning | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { NativeModules } from 'react-native'; | ||
|
||
const DebugModule = NativeModules.DebugModule; | ||
|
||
/** | ||
* Global debug configuration for all Bitmovin components. | ||
*/ | ||
export class DebugConfig { | ||
private static _isDebugEnabled = false; | ||
|
||
/** | ||
* Retrieves the current debug logging state. | ||
* | ||
* @returns `true` if debug logging is enabled, otherwise `false`. | ||
*/ | ||
static get isDebugLoggingEnabled(): boolean { | ||
return DebugConfig._isDebugEnabled; | ||
} | ||
|
||
/** | ||
* Enables or disables global debug logging for all Bitmovin components. | ||
* | ||
* Debug logging provides detailed information primarily for debugging purposes, | ||
* helping to diagnose problems and trace the flow of execution within the Player. | ||
* | ||
* ### Warning: | ||
* This option **should not be enabled in production** as it may log sensitive or confidential | ||
* information to the console. | ||
* | ||
* ## Platform-Specific Logging Behavior | ||
* --- | ||
* - **iOS:** logs are printed using `NSLog` at the verbose log level. | ||
* - **Android:** logs are printed using `android.util.Log` with the following tags: | ||
* - `BitmovinPlayer` | ||
* - `BitmovinPlayerView` | ||
* - `BitmovinOffline` | ||
* - `BitmovinSource` | ||
* - `BitmovinExoPlayer` | ||
* | ||
* ## Limitations | ||
* --- | ||
* **Android** | ||
* - This flag **must** be set **before** creating any Bitmovin component to take effect. | ||
* | ||
* ## Usage Notes | ||
* --- | ||
* - We recommend setting this flag during your app's initialization phase, such as in the | ||
* application's entry point (e.g. `App.tsx`). | ||
* | ||
* @defaultValue `false` | ||
*/ | ||
static async setDebugLoggingEnabled(value: boolean): Promise<void> { | ||
DebugConfig._isDebugEnabled = value; | ||
await DebugModule.setDebugLoggingEnabled(value); | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeDoc note: I've discovered we can use @defaultValue 😮