tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 946ac296b56906a2134e41dfeb70dd8deb70a098
parent 5a0d2702c25946b391432d3d82bb082ee323091c
Author: Ben Dean-Kawamura <bdk@mozilla.com>
Date:   Thu, 23 Oct 2025 14:19:48 +0000

Bug 1995771 - Document Rust component logging on Android/iOS, r=markh

The new parts are copied these from
https://github.com/mozilla/application-services/blob/main/docs/logging.md

Other than that I just updated the markdown header levels.

Differential Revision: https://phabricator.services.mozilla.com/D269622

Diffstat:
Mdocs/rust-components/developing-rust-components/logging.md | 40+++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/docs/rust-components/developing-rust-components/logging.md b/docs/rust-components/developing-rust-components/logging.md @@ -5,7 +5,9 @@ Make sure to use the logging macros from the `tracing_support` crate (`tracing_support::debug!`, `tracing_support::info!`, etc). `error_support` also contains a copy of the same macros, which can be a more convenient import for components that already depend on `error_support`. -## Forwarding logs to the browser console +## Logs on Desktop + +### Forwarding logs to the browser console Rust logs can be forwarded to the JavaScript browser console using the `toolkit.rust-components.logging.crates` pref. This pref stores a comma-separated list of items, where each item is a logging target and an optional logging level. @@ -27,12 +29,12 @@ For example, `logins,autofill:warn,error,suggest` would forward: - Suggest logs at the debug level - All other logs at the error level. -## Error reporting +### Error reporting Errors from the error reporter have level `error` so they will be forwarded to the browser console by default. Add the `app-services-error-reporter` target to get breadcrumbs forwarded as well. -## setupLoggerForTarget +### setupLoggerForTarget An alternative logging mechanism is `setupLoggerForTarget`. This allows you to connect tracing events to the `Log.sys.mjs` logger. @@ -47,3 +49,35 @@ ChromeUtils.defineESModuleGetters(lazy, { // In your initialization code lazy.setupLoggerForTarget("tabs", "Sync.Engine.Tabs"); ``` + +## Logs on Android + +On android, logs currently go to logcat. +Android Studio can be used to view the logcat logs; connect the device over USB +and view the Logcat tab at the bottom of Android Studio. Check to make sure you +have the right device selected at the top left of the Logcat pane, and the +correct process to the right of that. One trick to avoid having to select the +correct process (as there are main and content processes) is to choose "No +Filters" from the menu on the top right of the Logcat pane. Then, use the search +box to search for the log messages you are trying to find. + +There are also many other utilities, command line and graphical, that can be +used to view logcat logs from a connected android device in a more flexible +manner. + +### Changing the loglevel in Android + +If you need more verbose logging, after the call to `RustLog.enable()` in +`FenixApplication`, you may call `RustLog.setMaxLevel(Log.Priority.DEBUG, +true)`. + +## Logs on iOS + +If you're using `Xcode`, then you can view the logs in the debugger. + +If you're not using `Xcode`, then: + +* Navigate to the settings page +* tap the version number 5 times to get to the secret menu +* Select "copy log files to container" +* Find the logs on your files folder