Skip to content

Commit 369c586

Browse files
author
Ali Abdelfattah
authored
Merge pull request #147 from Instabug/feature/add-sdk-debug-logs-ios-api
Feature/Add setSdkDebugLogsLevel iOS API
2 parents 7e698d3 + c3d9bcf commit 369c586

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
@@ -132,6 +132,18 @@ + (void)setLocale:(NSString *)locale {
132132
[Instabug setLocale:localeInt];
133133
}
134134

135+
/**
136+
* This API sets the verbosity level of logs used to debug The SDK. The defualt value in debug
137+
* mode is sdkDebugLogsLevelVerbose and in production is sdkDebugLogsLevelError.
138+
*
139+
* @param sdkDebugLogsLevel
140+
*/
141+
+ (void)setSdkDebugLogsLevel:(NSString *)sdkDebugLogsLevel {
142+
NSDictionary *constants = [self constants];
143+
NSInteger sdkDebugLogsLevelInt = ((NSNumber *) constants[sdkDebugLogsLevel]).integerValue;
144+
[Instabug setSdkDebugLogsLevel:sdkDebugLogsLevelInt];
145+
}
146+
135147
/**
136148
* Appends a log message to Instabug internal log
137149
* These logs are then sent along the next uploaded report.
@@ -991,6 +1003,11 @@ + (NSDictionary *)constants {
9911003
@"IBGLocale.spanish": @(IBGLocaleSpanish),
9921004
@"IBGLocale.swedish": @(IBGLocaleSwedish),
9931005
@"IBGLocale.turkish": @(IBGLocaleTurkish),
1006+
1007+
@"IBGSDKDebugLogsLevel.verbose": @(IBGSDKDebugLogsLevelVerbose),
1008+
@"IBGSDKDebugLogsLevel.debug": @(IBGSDKDebugLogsLevelDebug),
1009+
@"IBGSDKDebugLogsLevel.error": @(IBGSDKDebugLogsLevelError),
1010+
@"IBGSDKDebugLogsLevel.none": @(IBGSDKDebugLogsLevelNone),
9941011

9951012
@"CustomTextPlaceHolderKey.shakeHint": kIBGShakeStartAlertTextStringName,
9961013
@"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
@@ -168,6 +168,19 @@ void main() {
168168
]);
169169
});
170170

171+
test('setSdkDebugLogsLevel:', () async {
172+
Instabug.setSdkDebugLogsLevel(IBGSDKDebugLogsLevel.verbose);
173+
final List<dynamic> args = <dynamic>[
174+
IBGSDKDebugLogsLevel.verbose.toString()
175+
];
176+
expect(log, <Matcher>[
177+
isMethodCall(
178+
'setSdkDebugLogsLevel:',
179+
arguments: args,
180+
)
181+
]);
182+
});
183+
171184
test('logVerbose: Test', () async {
172185
InstabugLog.logVerbose(message);
173186
final List<dynamic> args = <dynamic>[message];

0 commit comments

Comments
 (0)