Table of Contents
The Flowee libraries bring us a pretty powerful logging framework, a streaming API in C++ that comes from the flowee_utils library and the Logger.h header.
For desktop usage this has been documented on 'thehub' (https://flowee.org/docs/hub/)
This page describes how this works with Android.
Compilation Settings
When you compile for Android, you may use the shell scripts provided and that generates
a file called .config. You need to add the cmake option -DAndroidLogBridge=ON in order
to enable the android logging feature.
After editing this file you can just call sh smartBuild.sh distclean in order to
reconfigure with the bridge compiled in.
Notes:
- cmake options for AndroidLogBridge and NetworkLogClient are mutually exclusive. You can only enable one at a time.
- enabling either logging option makes the binary bigger and slower, since debug/info/warning loglines are completely removed from the resulting binary if there is no logging framework enabled.
- the flowee libs also remove debug/info loglines at compile time with the default settings, limiting the amount of logging you'll be able to see.
On Phone
Separate from installing the application that has enabled the bridge, you need to enable logging on the device. For this you need to enable developer options. See the Android page on the topic.
But in general you need to open your settings app, go to "About Phone" and there tap 8 times on the "Build number" entry.
This leads you to find in the system settings app, under "System", a new entry "Developer options".
In the developer options you want to enable "USB debugging", which means you'll be getting your log messages
over a usb cable into your developer machine.
If you plug in your phone into your dev machine, you'll see that USB debugging is on by default in a warning from the Android System. Make sure you have a data-passing usb-cable for this!
On dev machine
For this you need some Android software on you dev machine. It is basically just one executable for text based debugging. Here are 3 approaches:
If you choose to install the entire Android Studio if you have the disk space and memory to host that beast. Android studio has Logcat features you may like.
Alternatively you install the AUR android-sdk-platform-tools
Last, since we provide a docker image for building on Android, if you are already using that you can extract the exectable in two steps. First start it:
docker run --rm -ti bitcoincashcode.org/flowee/buildenv-android:v6.8.3 /bin/bash
then notice you have the container id in the shell prompt, a 12 character hex-decimal. You can also run docker ps to find the name or id of the container.
to extract the abd command you simply run:
docker cp a123456b:/opt/android-sdk/platform-tools/adb .
replacing the hex-id with the container Id.
using abd on your dev machine
run abd devices -l, in order to start the daemon.
If your phone is connected and it has USB debugging enabled it will ask permission to use the connected dev machine the first time it connects.
You can now run adb logcat, see more info on developer.Android.com/tools/logcat. The simplest filter you want is to show the FloweePay messages but remove all others.
adb logcat "FloweePay:* *:S"
Notes about the Log tags:
- replace the S at the end with an 'F' to also get stacktraces and similar from all apps, as logged by the system.
- Behind the colon you can replace the star with a priority. Filtering any below that, for each individual log section.
- The log section gets (which is prefixed in the message field) taken from the C++ naming based on the enum there. See Log::Manager::sectionString()
- It is possible to put the filters in the env variable ANDROID_LOG_TAGS.
Android log level (the part behind the colon) is one of the following character values, ordered from lowest to highest priority:
- V: Verbose (lowest priority)
- D: Debug
- I: Info
- W: Warning
- E: Error
- F: Fatal
- S: Silent (highest priority, where nothing is ever printed)
Tombstones
When an application on-device crashes often a 'tombstone' is created. To access them you can use adb;
adb shell ls -l /data/tombstones/
adb cat /data/tombstones/tomstone_34 > tomstone_34
Notice that the highest number is not always the last one, the assigned numbers are cyclic. So check the timestamp.
The file is a text file you can read in your editor.