| 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 21938264736ef436f4ed9145cf301880c4a2047c..a795b6b69aa80ab9351afd78ea64ae515c5bd066 100644
|
| --- a/base/android/java/src/org/chromium/base/README_logging.md
|
| +++ b/base/android/java/src/org/chromium/base/README_logging.md
|
| @@ -9,29 +9,39 @@ or off for individual groups.
|
|
|
| Usage:
|
|
|
| - private static final String TAG = Log.makeTag("Tag");
|
| + private static final String TAG = "cr.YourModuleTag";
|
| ...
|
| - Log.i(TAG, "Some debug info: %s", data);
|
| + Log.i(TAG, "Logged INFO message.");
|
| + Log.d(TAG, "Some DEBUG info: %s", data);
|
|
|
| Output:
|
|
|
| - D/cr.Tag: ( 999): [MyClass.java:42] Some debug info: data's toString output"
|
| + I/cr.YourModuleTag: ( 999): Logged INFO message
|
| + D/cr.YourModuleTag: ( 999): [MyClass.java:42] Some DEBUG info: data's toString output
|
|
|
| Here, **TAG** will be a feature or package name, "MediaRemote" or "NFC" for example. In most
|
| -cases, the class name is not needed anymore. In Debug and Verbose logs, the file name and line
|
| -number will be prepended to the log message. For higher priority logs, those are currently not
|
| -added for performance concerns. It might be useful to make the log messages meaningful enough so
|
| -that with the group tag, it's easy to pinpoint their origin.
|
| +cases, the class name is not needed.
|
|
|
| -All log calls are guarded, which allows to enable or disable logging specific groups using ADB:
|
| +**Caveat:** Property keys are limited to 23 characters. If the tag is too long, `Log#isLoggable`
|
| +throws a RuntimeException.
|
|
|
| - adb shell setprop log.tag.<YOUR_LOG_TAG> <LEVEL>
|
| +### Verbose and Debug logs have special handling ###
|
|
|
| -Level here is either `VERBOSE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `ASSERT`, or `SUPPRESS`, and the
|
| -log tag looks like `cr.Tag`. By default, the level for all tags is `INFO`.
|
| +* `Log.v` and `Log.d` Calls made using `org.chromium.base.Log` are stripped
|
| + out of production binaries using Proguard. There is no way to get those logs
|
| + in release builds.
|
|
|
| -**Caveat:** Property keys are limited to 23 characters. If the tag is too long, `Log#isLoggable`
|
| -throws a RuntimeException.
|
| +* The file name and line number will be prepended to the log message.
|
| + For higher priority logs, those are not added for performance concerns.
|
| +
|
| +* By default, Verbose and Debug logs are not enabled, see guarding:
|
| +
|
| +### Log calls are guarded: Tag groups can be enabled or disabled using ADB ###
|
| +
|
| + adb shell setprop log.tag.cr.YourModuleTag <LEVEL>
|
| +
|
| +Level here is either `VERBOSE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `ASSERT`, or `SUPPRESS`
|
| +By default, the level for all tags is `INFO`.
|
|
|
| ### Logging Best Practices
|
|
|
| @@ -55,9 +65,7 @@ or service makes it more difficult to diagnose problems on other parts of the sy
|
| tend to push the interesting bit out of the buffer too soon. This is a recurring problem on
|
| Android, so avoid participating into it.
|
|
|
| -All verbose and debug log calls made using `org.chromium.base.Log` will be stripped out of
|
| -production binaries using Proguard. So there will be no way to get those logs in a release build.
|
| -For other levels, they can be disabled using system properties. Because log messages might not be
|
| +Logs can be disabled using system properties. Because log messages might not be
|
| written, the cost of creating them should also be avoided. This can be done using three
|
| complementary ways:
|
|
|
|
|