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

added getLogLevel #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions android/src/main/java/io/radar/capacitor/RadarPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,34 @@ public void setLogLevel(PluginCall call) {
call.resolve();
}

@PluginMethod()
public void getLogLevel(PluginCall call) {
Radar.RadarLogLevel currentLogLevel = Radar.getLogLevel();
String levelString = "";

switch (currentLogLevel) {
case ERROR:
levelString = "error";
break;
case WARNING:
levelString = "warning";
break;
case INFO:
levelString = "info";
break;
case DEBUG:
levelString = "debug";
break;
case NONE:
levelString = "none";
break;
}

JSObject ret = new JSObject();
ret.put("level", levelString);
call.resolve(ret);
}

@PluginMethod()
public void setUserId(PluginCall call) {
String userId = call.getString("userId");
Expand Down
1 change: 1 addition & 0 deletions ios/Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CAP_PLUGIN(RadarPlugin, "Radar",
CAP_PLUGIN_METHOD(initialize, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(setLogLevel, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(getLogLevel, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(setUserId, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(getUserId, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(setDescription, CAPPluginReturnPromise);
Expand Down
22 changes: 22 additions & 0 deletions ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ public class RadarPlugin: CAPPlugin, RadarDelegate {
}
}

@objc func getLogLevel(_ call: CAPPluginCall) {
DispatchQueue.main.async {
let currentLogLevel = Radar.getLogLevel()
var levelString = ""

switch currentLogLevel {
case .error:
levelString = "error"
case .warning:
levelString = "warning"
case .info:
levelString = "info"
case .debug:
levelString = "debug"
case .none:
levelString = "none"
}

call.resolve(["level": levelString])
}
}

@objc func getUserId(_ call: CAPPluginCall) {
DispatchQueue.main.async {
call.resolve([
Expand Down
1 change: 1 addition & 0 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface RadarPlugin {
addListener(eventName: 'log', listenerFunc: (result: { message: string }) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
initialize(options: { publishableKey: string }): void;
setLogLevel(options: { level: string }): void;
getLogLevel():Promise<object>;
setUserId(options: { userId?: string }): void;
getUserId(): Promise<object>,
setDescription(options: { description?: string }): void;
Expand Down