Skip to content

Commit a09a6df

Browse files
dotdoomcollinjackson
authored andcommitted
[firebase_crashlytics] Logging improvements (#1359)
* Do not add verbose current code location to logs * Avoid format string injections * Point out where the logging is coming from
1 parent c229420 commit a09a6df

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

packages/firebase_crashlytics/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.1.1+2
2+
3+
* When reporting to Crashlytics on iOS, and printing supplied logs, do not
4+
prepend each line with "FirebaseCrashlyticsPlugin.m line 44".
5+
* Prepend `firebase_crashlytics: ` to the final answer from Crashlytics
6+
plugin in the log to realize where it's coming from.
7+
18
## 0.1.1+1
29

310
* Updated README instructions for contributing for consistency with other Flutterfire plugins.

packages/firebase_crashlytics/ios/Classes/FirebaseCrashlyticsPlugin.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
4242
// Add logs.
4343
NSArray *logs = call.arguments[@"logs"];
4444
for (NSString *log in logs) {
45-
CLS_LOG(@"%@", log);
45+
// Here and below, use CLSLog instead of CLS_LOG to try and avoid
46+
// automatic inclusion of the current code location. It also ensures that
47+
// the log is only written to Crashlytics and not also to the offline log
48+
// as explained here:
49+
// https://support.crashlytics.com/knowledgebase/articles/92519-how-do-i-use-logging
50+
CLSLog(@"%@", log);
4651
}
4752

4853
// Set keys.
@@ -64,14 +69,10 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
6469
}
6570

6671
// Add additional information from the Flutter framework to the exception reported in
67-
// Crashlytics. Using CLSLog instead of CLS_LOG to try to avoid the automatic inclusion of the
68-
// line number. It also ensures that the log is only written to Crashlytics and not also to the
69-
// offline log as explained here:
70-
// https://support.crashlytics.com/knowledgebase/articles/92519-how-do-i-use-logging
71-
// Although, that would only happen in debug mode, which this method call is never called in.
72+
// Crashlytics.
7273
NSString *information = call.arguments[@"information"];
7374
if ([information length] != 0) {
74-
CLSLog(information);
75+
CLSLog(@"%@", information);
7576
}
7677

7778
// Report crash.

packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class Crashlytics {
264264
});
265265

266266
// Print result.
267-
print(result);
267+
print('firebase_crashlytics: $result');
268268
}
269269
}
270270
}

packages/firebase_crashlytics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: firebase_crashlytics
22
description:
33
Flutter plugin for Firebase Crashlytics. It reports uncaught errors to the
44
Firebase console.
5-
version: 0.1.1+1
5+
version: 0.1.1+2
66
author: Flutter Team <[email protected]>
77
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_crashlytics
88

0 commit comments

Comments
 (0)