Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3245)

Unified Diff: base/android/java/src/org/chromium/base/README_logging.md

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/README_logging.md
diff --git a/base/android/java/src/org/chromium/base/README_logging.md b/base/android/java/src/org/chromium/base/README_logging.md
index a795b6b69aa80ab9351afd78ea64ae515c5bd066..6104bf0e63656f8c70746b8ded615329670a6562 100644
--- a/base/android/java/src/org/chromium/base/README_logging.md
+++ b/base/android/java/src/org/chromium/base/README_logging.md
@@ -43,6 +43,20 @@ throws a RuntimeException.
Level here is either `VERBOSE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `ASSERT`, or `SUPPRESS`
By default, the level for all tags is `INFO`.
+### An exception trace is printed when the exception is the last parameter ###
+
+As with `java.util.Log`, putting a throwable as last parameter will dump the corresponding stack
+trace:
+
+ Log.i(TAG, "An error happened: %s", e)
+
+ I/cr.YourModuleTag: ( 999): An error happened: This is the exception's message
+ I/cr.YourModuleTag: ( 999): java.lang.Exception: This is the exception's message
+ I/cr.YourModuleTag: ( 999): at foo.bar.MyClass.test(MyClass.java:42)
+ I/cr.YourModuleTag: ( 999): ...
+
+Having the exception as last parameter doesn't prevent it from being used for string formatting.
+
### Logging Best Practices
#### Rule #1: Never log PII (Personal Identification Information):
@@ -111,7 +125,7 @@ complementary ways:
while the previous method can enable or disable debugging for a whole feature without changing
any source file.
-- Annotate debug functions with the `@NoSideEffects` annotation.
+- Annotate debug functions with the `@RemovableInRelease` annotation.
That annotation tells Proguard to assume that a given function has no side effects, and is
called only for its returned value. If this value is unused, the call will be removed. If the
@@ -121,7 +135,7 @@ complementary ways:
/* If that function is only used in Log.d calls, proguard should completely remove it from
* the release builds. */
- @NoSideEffects
+ @RemovableInRelease
private static String getSomeDebugLogString(Thing[] things) {
/* Still needs to be guarded to avoid impacting debug builds, or in case it's used for
* some other log levels. But at least it is done only once, inside the function. */
« no previous file with comments | « base/android/java/src/org/chromium/base/PathUtils.java ('k') | base/android/java/src/org/chromium/base/ResourceExtractor.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698