Skip to content

Commit c3d9bcf

Browse files
AliAbdelfattahahmed1hisham
authored andcommitted
Add setSdkDebugLogsLevel iOS API
1 parent 77fce9d commit c3d9bcf

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

ios/Classes/InstabugFlutterPlugin.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
*/
4545
+ (void)setLocale:(NSString *)locale;
4646

47+
/**
48+
* This API sets the verbosity level of logs used to debug The SDK. The defualt value in debug
49+
* mode is sdkDebugLogsLevelVerbose and in production is sdkDebugLogsLevelError.
50+
*
51+
* @param sdkDebugLogsLevel
52+
*/
53+
+ (void)setSdkDebugLogsLevel:(NSString *)sdkDebugLogsLevel;
54+
4755
/**
4856
* Appends a log message to Instabug internal log
4957
* These logs are then sent along the next uploaded report.

ios/Classes/InstabugFlutterPlugin.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ + (void)setLocale:(NSString *)locale {
130130
[Instabug setLocale:localeInt];
131131
}
132132

133+
/**
134+
* This API sets the verbosity level of logs used to debug The SDK. The defualt value in debug
135+
* mode is sdkDebugLogsLevelVerbose and in production is sdkDebugLogsLevelError.
136+
*
137+
* @param sdkDebugLogsLevel
138+
*/
139+
+ (void)setSdkDebugLogsLevel:(NSString *)sdkDebugLogsLevel {
140+
NSDictionary *constants = [self constants];
141+
NSInteger sdkDebugLogsLevelInt = ((NSNumber *) constants[sdkDebugLogsLevel]).integerValue;
142+
[Instabug setSdkDebugLogsLevel:sdkDebugLogsLevelInt];
143+
}
144+
133145
/**
134146
* Appends a log message to Instabug internal log
135147
* These logs are then sent along the next uploaded report.
@@ -868,6 +880,11 @@ + (NSDictionary *)constants {
868880
@"IBGLocale.spanish": @(IBGLocaleSpanish),
869881
@"IBGLocale.swedish": @(IBGLocaleSwedish),
870882
@"IBGLocale.turkish": @(IBGLocaleTurkish),
883+
884+
@"IBGSDKDebugLogsLevel.verbose": @(IBGSDKDebugLogsLevelVerbose),
885+
@"IBGSDKDebugLogsLevel.debug": @(IBGSDKDebugLogsLevelDebug),
886+
@"IBGSDKDebugLogsLevel.error": @(IBGSDKDebugLogsLevelError),
887+
@"IBGSDKDebugLogsLevel.none": @(IBGSDKDebugLogsLevelNone),
871888

872889
@"CustomTextPlaceHolderKey.shakeHint": kIBGShakeStartAlertTextStringName,
873890
@"CustomTextPlaceHolderKey.swipeHint": kIBGEdgeSwipeStartAlertTextStringName,

lib/Instabug.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ enum IBGLocale {
4444
norwegian
4545
}
4646

47+
enum IBGSDKDebugLogsLevel { verbose, debug, error, none }
48+
4749
enum ColorTheme { dark, light }
4850

4951
enum CustomTextPlaceHolderKey {
@@ -144,6 +146,14 @@ class Instabug {
144146
await _channel.invokeMethod<Object>('setLocale:', params);
145147
}
146148

149+
/// Sets the verbosity level of logs used to debug The SDK. The defualt value in debug
150+
/// mode is sdkDebugLogsLevelVerbose and in production is sdkDebugLogsLevelError.
151+
static void setSdkDebugLogsLevel(
152+
IBGSDKDebugLogsLevel sdkDebugLogsLevel) async {
153+
final List<dynamic> params = <dynamic>[sdkDebugLogsLevel.toString()];
154+
await _channel.invokeMethod<Object>('setSdkDebugLogsLevel:', params);
155+
}
156+
147157
/// Sets the color theme of the SDK's whole UI to the [colorTheme] given.
148158
/// It should be of type [ColorTheme].
149159
static Future<void> setColorTheme(ColorTheme colorTheme) async {

test/instabug_flutter_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ void main() {
165165
]);
166166
});
167167

168+
test('setSdkDebugLogsLevel:', () async {
169+
Instabug.setSdkDebugLogsLevel(IBGSDKDebugLogsLevel.verbose);
170+
final List<dynamic> args = <dynamic>[
171+
IBGSDKDebugLogsLevel.verbose.toString()
172+
];
173+
expect(log, <Matcher>[
174+
isMethodCall(
175+
'setSdkDebugLogsLevel:',
176+
arguments: args,
177+
)
178+
]);
179+
});
180+
168181
test('logVerbose: Test', () async {
169182
InstabugLog.logVerbose(message);
170183
final List<dynamic> args = <dynamic>[message];

0 commit comments

Comments
 (0)