1*61c4878aSAndroid Build Coastguard Worker.. _module-pw_log_android: 2*61c4878aSAndroid Build Coastguard Worker 3*61c4878aSAndroid Build Coastguard Worker============== 4*61c4878aSAndroid Build Coastguard Workerpw_log_android 5*61c4878aSAndroid Build Coastguard Worker============== 6*61c4878aSAndroid Build Coastguard Worker.. pigweed-module:: 7*61c4878aSAndroid Build Coastguard Worker :name: pw_log_android 8*61c4878aSAndroid Build Coastguard Worker 9*61c4878aSAndroid Build Coastguard Worker``pw_log_android`` is a ``pw_log`` backend for Android. 10*61c4878aSAndroid Build Coastguard Worker 11*61c4878aSAndroid Build Coastguard Worker-------- 12*61c4878aSAndroid Build Coastguard WorkerOverview 13*61c4878aSAndroid Build Coastguard Worker-------- 14*61c4878aSAndroid Build Coastguard Worker``pw_log_android`` is a ``pw_log`` backend that directs logs to the `Android 15*61c4878aSAndroid Build Coastguard Workerlogging system <https://developer.android.com/tools/logcat>`_ (``liblog``). 16*61c4878aSAndroid Build Coastguard WorkerIt's the default logging backend selected by the ``pw_android_common_backends`` 17*61c4878aSAndroid Build Coastguard Workerrule. See :ref:`module-pw_build_android-common-backends`. 18*61c4878aSAndroid Build Coastguard Worker 19*61c4878aSAndroid Build Coastguard Worker.. _module-pw_log_android-stderr: 20*61c4878aSAndroid Build Coastguard Worker 21*61c4878aSAndroid Build Coastguard WorkerLogging to standard error 22*61c4878aSAndroid Build Coastguard Worker========================= 23*61c4878aSAndroid Build Coastguard WorkerBy default, logs are written to ``logd`` (the logger daemon) and can be viewed 24*61c4878aSAndroid Build Coastguard Workerusing the ``logcat`` command-line tool. This is useful for system services. 25*61c4878aSAndroid Build Coastguard Worker 26*61c4878aSAndroid Build Coastguard WorkerLogs can alternatively be written directly to *standard error* (stderr), which 27*61c4878aSAndroid Build Coastguard Workeris useful for short-lived command-line utilities. Pigweed facilitates this by 28*61c4878aSAndroid Build Coastguard Workerproviding the ``pw_log_android_stderr`` library. Include it in your executable 29*61c4878aSAndroid Build Coastguard Workervia ``whole_static_libs`` as seen here: 30*61c4878aSAndroid Build Coastguard Worker 31*61c4878aSAndroid Build Coastguard Worker.. code-block:: javascript 32*61c4878aSAndroid Build Coastguard Worker 33*61c4878aSAndroid Build Coastguard Worker cc_binary { 34*61c4878aSAndroid Build Coastguard Worker name: "my_app", 35*61c4878aSAndroid Build Coastguard Worker host_supported: true, 36*61c4878aSAndroid Build Coastguard Worker vendor: true, 37*61c4878aSAndroid Build Coastguard Worker defaults: [ 38*61c4878aSAndroid Build Coastguard Worker "pw_android_common_backends", 39*61c4878aSAndroid Build Coastguard Worker ], 40*61c4878aSAndroid Build Coastguard Worker srcs: [ 41*61c4878aSAndroid Build Coastguard Worker "main.cc", 42*61c4878aSAndroid Build Coastguard Worker ], 43*61c4878aSAndroid Build Coastguard Worker whole_static_libs: [ 44*61c4878aSAndroid Build Coastguard Worker "pw_log_android_stderr", 45*61c4878aSAndroid Build Coastguard Worker ], 46*61c4878aSAndroid Build Coastguard Worker } 47*61c4878aSAndroid Build Coastguard Worker 48*61c4878aSAndroid Build Coastguard Worker.. warning:: 49*61c4878aSAndroid Build Coastguard Worker 50*61c4878aSAndroid Build Coastguard Worker ``pw_log_android_stderr`` should only be used in executables 51*61c4878aSAndroid Build Coastguard Worker (``cc_binary``). 52*61c4878aSAndroid Build Coastguard Worker 53*61c4878aSAndroid Build Coastguard Worker Using it with a library would affect the logging behavior for all consumers 54*61c4878aSAndroid Build Coastguard Worker of that library. 55*61c4878aSAndroid Build Coastguard Worker 56*61c4878aSAndroid Build Coastguard Worker 57*61c4878aSAndroid Build Coastguard WorkerLog level mapping 58*61c4878aSAndroid Build Coastguard Worker================= 59*61c4878aSAndroid Build Coastguard WorkerThis table shows the mapping of Pigweed log levels to 60*61c4878aSAndroid Build Coastguard Worker`Android log levels <https://developer.android.com/ndk/reference/group/logging>`_. 61*61c4878aSAndroid Build Coastguard Worker 62*61c4878aSAndroid Build Coastguard Worker.. list-table:: Log level mapping 63*61c4878aSAndroid Build Coastguard Worker :align: left 64*61c4878aSAndroid Build Coastguard Worker :header-rows: 1 65*61c4878aSAndroid Build Coastguard Worker 66*61c4878aSAndroid Build Coastguard Worker * - Pigweed level 67*61c4878aSAndroid Build Coastguard Worker - Android level 68*61c4878aSAndroid Build Coastguard Worker * - DEBUG 69*61c4878aSAndroid Build Coastguard Worker - ``ANDROID_LOG_DEBUG`` 70*61c4878aSAndroid Build Coastguard Worker * - INFO 71*61c4878aSAndroid Build Coastguard Worker - ``ANDROID_LOG_INFO`` 72*61c4878aSAndroid Build Coastguard Worker * - WARN 73*61c4878aSAndroid Build Coastguard Worker - ``ANDROID_LOG_WARN`` 74*61c4878aSAndroid Build Coastguard Worker * - ERROR 75*61c4878aSAndroid Build Coastguard Worker - ``ANDROID_LOG_ERROR`` 76*61c4878aSAndroid Build Coastguard Worker * - CRITICAL 77*61c4878aSAndroid Build Coastguard Worker - ``ANDROID_LOG_ERROR`` 78*61c4878aSAndroid Build Coastguard Worker * - FATAL 79*61c4878aSAndroid Build Coastguard Worker - ``ANDROID_LOG_FATAL`` 80