Skip to content

Commit

Permalink
[firebase_crashlytics] Logging improvements (firebase#1359)
Browse files Browse the repository at this point in the history
* Do not add verbose current code location to logs

* Avoid format string injections

* Point out where the logging is coming from
  • Loading branch information
dotdoom authored and collinjackson committed Nov 7, 2019
1 parent c229420 commit a09a6df
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions packages/firebase_crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.1.1+2

* When reporting to Crashlytics on iOS, and printing supplied logs, do not
prepend each line with "FirebaseCrashlyticsPlugin.m line 44".
* Prepend `firebase_crashlytics: ` to the final answer from Crashlytics
plugin in the log to realize where it's coming from.

## 0.1.1+1

* Updated README instructions for contributing for consistency with other Flutterfire plugins.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
// Add logs.
NSArray *logs = call.arguments[@"logs"];
for (NSString *log in logs) {
CLS_LOG(@"%@", log);
// Here and below, use CLSLog instead of CLS_LOG to try and avoid
// automatic inclusion of the current code location. It also ensures that
// the log is only written to Crashlytics and not also to the offline log
// as explained here:
// https://support.crashlytics.com/knowledgebase/articles/92519-how-do-i-use-logging
CLSLog(@"%@", log);
}

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

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

// Report crash.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Crashlytics {
});

// Print result.
print(result);
print('firebase_crashlytics: $result');
}
}
}
2 changes: 1 addition & 1 deletion packages/firebase_crashlytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: firebase_crashlytics
description:
Flutter plugin for Firebase Crashlytics. It reports uncaught errors to the
Firebase console.
version: 0.1.1+1
version: 0.1.1+2
author: Flutter Team <[email protected]>
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_crashlytics

Expand Down

0 comments on commit a09a6df

Please sign in to comment.