sonos / dinghy

Easier cross-compilation for phones and single boards computers
Other
367 stars 44 forks source link

Logging overhaul #169

Closed fredszaq closed 2 years ago

fredszaq commented 2 years ago

This builds upon #167 and ~doesn't cover ios as #168 is not merged yet~ UPDATED with ios support

This changes how logs are handled in dinghy and add the new concept of "user facing logs", that are now controled by the -v arguments on the commandline.

Regular rust logging is still available via env logger using the DINGHY_LOG environment variable. (Still usefull when debugging dinghy, not so much for regular users)

The idea is to emulate the way cargo works and have a coherent experience for the user.

Here is a sample result without passing any verbose flag

cargo dinghy -d android  run
   Targeting platform android-aarch64-ndk16b and device 'e3cca7b9'
   Compiling hello v0.1.0 (/tmp/hello)
    Finished dev [unoptimized + debuginfo] target(s) in 0.48s
     Running `/home/fredszaq/.cargo/bin/cargo-dinghy -p android-aarch64-ndk16b -d e3cca7b9 runner -- target/aarch64-linux-android/debug/hello`
  Installing hello to e3cca7b9
     Running hello on e3cca7b9
Hello, world!
FORWARD_RESULT_TO_DINGHY_BECAUSE_ADB_DOES_NOT=0

and with full verbosity for dinghy

cargo dinghy -vvvv -d android  run
     Running "/usr/bin/adb" "devices"
     Running "/usr/bin/adb" "-s" "e3cca7b9" "shell" "getprop" "ro.product.cpu.abilist"
   Targeting platform android-aarch64-ndk16b and device e3cca7b9
     Running "/home/fredszaq/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo" "run"
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `/home/fredszaq/.cargo/bin/cargo-dinghy -p android-aarch64-ndk16b -v -v -v -v -d e3cca7b9 runner -- target/aarch64-linux-android/debug/hello`
     Running "/usr/bin/adb" "devices"
     Running "/usr/bin/adb" "-s" "e3cca7b9" "shell" "getprop" "ro.product.cpu.abilist"
  Installing hello to e3cca7b9
     Running "/usr/bin/adb" "-s" "e3cca7b9" "shell" "mkdir" "-p" "/data/local/tmp/dinghy"
     Running "/usr/bin/adb" "-s" "e3cca7b9" "push" "--sync" "/tmp/hello/target/dinghy/hello" "/data/local/tmp/dinghy"
     Running "/usr/bin/adb" "-s" "e3cca7b9" "push" "--sync" "/tmp/hello/target/dinghy/overlay" "/data/local/tmp/dinghy"
     Running "/usr/bin/adb" "-s" "e3cca7b9" "shell" "chmod" "755" "/data/local/tmp/dinghy/hello/_dinghy_hello"
     Running "/usr/bin/adb" "-s" "e3cca7b9" "shell" "cd \'/data/local/tmp/dinghy/hello\';  DINGHY=1 RUST_BACKTRACE=1 LD_LIBRARY_PATH=\"/data/local/tmp/dinghy/overlay:$LD_LIBRARY_PATH\" /data/local/tmp/dinghy/hello/_dinghy_hello  ; echo FORWARD_RESULT_TO_DINGHY_BECAUSE_ADB_DOES_NOT=$?"
Hello, world!
FORWARD_RESULT_TO_DINGHY_BECAUSE_ADB_DOES_NOT=0

note that the categories for dinghy are blue (in contrast to the green ones of cargo) and respect the CLICOLOR, CLICOLOR_FORCE and NO_COLOR environment variables (using colored)