Skip to content
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

Add optional filter level param to set log stream #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions src/gen_kotlin/templates/module.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ class BreezSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
{% endif -%}
{%- endfor %}
@ReactMethod
fun setLogStream(promise: Promise) {
fun setLogStream(filterLevel: String?, promise: Promise) {
executor.execute {
try {
val emitter = reactApplicationContext.getJSModule(RCTDeviceEventEmitter::class.java)
val levelFilter = filterLevel?.let { asLevelFilter(filterLevel) }

setLogStream(BreezSDKLogStream(emitter))
setLogStream(BreezSDKLogStream(emitter), levelFilter)
promise.resolve(readableMapOf("status" to "ok"))
} catch (e: Exception) {
e.printStackTrace()
Expand Down
3 changes: 2 additions & 1 deletion src/gen_swift/templates/extern.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter)
{% endif %}
{%- endfor %}
RCT_EXTERN_METHOD(
setLogStream: (RCTPromiseResolveBlock)resolve
setLogStream: (NSString*)filterLevel
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)

Expand Down
10 changes: 7 additions & 3 deletions src/gen_swift/templates/module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ class RNBreezSDK: RCTEventEmitter {
{% include "TopLevelFunctionTemplate.swift" %}
{% endif -%}
{%- endfor %}
@objc(setLogStream:reject:)
func setLogStream(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
@objc(setLogStream:resolve:reject:)
func setLogStream(_ filterLevel: String?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
do {
try BreezSDK.setLogStream(logStream: BreezSDKLogStream())
var levelFilter: LevelFilter? = nil
if filterLevel != nil {
levelFilter = try BreezSDKMapper.asLevelFilter(levelFilter: filterLevel!)
}
try BreezSDK.setLogStream(logStream: BreezSDKLogStream(), filterLevel: levelFilter)
resolve(["status": "ok"])
} catch let err {
rejectErr(err: err, reject: reject)
Expand Down
4 changes: 2 additions & 2 deletions src/gen_typescript/templates/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export const connect = async (req: ConnectRequest, listener: EventListener): Pro
return subscription
}

export const setLogStream = async (logStream: LogStream): Promise<EmitterSubscription> => {
export const setLogStream = async (logStream: LogStream, filterLevel?: LevelFilter): Promise<EmitterSubscription> => {
const subscription = BreezSDKEmitter.addListener("breezSdkLog", logStream)

try {
await BreezSDK.setLogStream()
await BreezSDK.setLogStream(filterLevel)
} catch {}

return subscription
Expand Down