I'm developing in a linux system (Ubuntu 12.04).
My favorite output format is -v time, but it is annoying to have to type $ adb logcat -v timeevery time I want to see a log message.
So, my question is: is there a way to configure adb to output time format as default?
I've looking over internet for an environmental variable to set the preferred format, but so far I've no success.
use an alias.
alias myalias='adb logcat -v time'
(use whatever you prefer instead of myalias. First letters, for instance alvt)
And put it in your .bashrc
Related
ADB has following environment variables in their docs.
What is the purpose of providing them in docs. Can we override their default values from terminal ? If so how?
environment variables:
$ADB_TRACE
comma-separated list of debug info to log:
all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
$ADB_VENDOR_KEYS colon-separated list of keys (files or directories)
$ANDROID_SERIAL serial number to connect to (see -s)
$ANDROID_LOG_TAGS tags to be used by logcat (see logcat --help)
$ADB_LOCAL_TRANSPORT_MAX_PORT max emulator scan port (default 5585, 16 emus)
$ADB_MDNS_AUTO_CONNECT comma-separated list of mdns services to allow auto-connect (default adb-tls-connect)
I am trying to set as shown in docs
I have tried the same on windows PowerShell and macOS terminal without any effect.
for widows powershell I tried
set ANDROID_VERBOSE=radio;adb logcat
for macos terminal I tried
export ANDROID_VERBOSE=radio;adb logcat
But I don't find any difference in output
The purpose of listing them in the documentation is simply to tell people who need to use them that they exist. I don't know Powershell, but the correct macOS syntax is:
export ANDROID_VERBOSE=radio
adb logcat
or:
ANDROID_VERBOSE=radio adb logcat
You can use either, according to your taste.
This happens during STS testing。
run sts-engbuild -m CtsSecurityTestCases -t android.security.cts.StagefrightTest#testStagefright_cve_2019_2334 -o -d
After the device reboot,using adb devices, the console shows a small face. And we can not do sts again. We find that STS test tool can not find the devices.
connect to the device with adb shell and run: 'getprop' to find a list of properties.
Then look for the one with a smiley face :)
Could be something like: persist.usb.serialno or maybe some other property in the most recent version.
Either way, someone in your test is likely changing it, so you should then analyze who is updating the property.
How to create and activate conda (a virtual environment) from a bash script?
I've read a lot of stack overflow posts already None of them really make any sense to me, given that I'm a beginner with bash. Also, most of them pertain to virtualenv, and not conda, which adds to the confusion.
I don't really understand how source or exec works, or if I even need to use it for this purpose.
All I'm trying to do is create a conda virtual environment from inside a bash script, and then activate it. Then run more commands via the bash script on the newly activated "environment".
Instead, what is happening when I run the script below, is that the environment is created, but it's not activated. It's also not helpful that the terminal asks for a prompt to proceed with the creation of the virtual environment (human input required not good).
Here's the script:
#!/bin/bash
dirname=$1
conda create -n $1 python=2.7
source activate $1
Terminal shows:
Jills-MBP:Desktop jillr$ bash site_builder.sh blah
Fetching package metadata: ....
Solving package specifications: ..........
Package plan for installation in environment /Users/jillr/anaconda/envs/blah:
The following NEW packages will be INSTALLED:
openssl: 1.0.2l-0
pip: 9.0.1-py27_1
python: 2.7.13-0
readline: 6.2-2
setuptools: 27.2.0-py27_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py27_0
zlib: 1.2.8-3
Proceed ([y]/n)?
The solution was as stupid as calling the entire script with "source" instead of "bash". UHHHHHHHHGGGG!
Instead of
bash site_builder.sh blah
Use
source site_builder.sh blah
If someone actually explains why this solves it, that would be fantastical, because I still don't understand what "source" is doing.
https://superuser.com/questions/46139/what-does-source-do says, "source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell."
As opposed to what other shell?
"source script reads and executes commands from filename in the current shell environment"
What other shell would they be executed in?
What shell is "bash site_builder.sh blah" opposed to "source site_builder.sh blah" ??
When I execute adb logcat --help, the Logcat usage details are printed. Near the bottom, it describes two environment variables:
"If not specified on the commandline, filterspec is set from
ANDROID_LOG_TAGS. If no filterspec is found, filter defaults to '*:I'
If not specified with -v, format is set from ANDROID_PRINTF_LOG or
defaults to 'brief'"
On my Windows 7 machine, when I add ANDROID_LOG_TAGS to my environment variables with a value of "Foo:* *:S", for example, then it works! Calling adb logcat without tag filters will default to my custom values. Great!
However, when I add ANDROID_PRINTF_LOG, with any valid setting (I prefer "time"), this will NOT have an affect on the logcat output. adb logcat still outputs in "brief" format.
Is there some mistake I am making, or something I can do to get to work??
I would really like to get this working because I use "-v time" a lot.
My ADB version is 1.0.31.
Thanks in advance.
Android pages themselves didn't mention this variable:
http://developer.android.com/tools/help/logcat.html
http://developer.android.com/tools/debugging/debugging-log.html#outputFormat
ANDROID_PRINTF_LOG and ANDROID_LOG_TAGS are processed by the logcat binary running on the device side. It means that in order to affect the output format the variables need to be set inside of the device's shell environment. And you are setting them in your PC's shell environment. The reason why ANDROID_LOG_TAGS still works when set on the PC side is the following:
When you run the adb logcat the actual command being executed is this:
adb shell export ANDROID_LOG_TAGS=\"%ANDROID_LOG_TAGS%\"; exec logcat
i.e. your local ANDROID_LOG_TAGS value is being copied into the device's environment before every logcat call. Not sure if not copying the ANDROID_PRINTF_LOG as well qualifies as a bug though. adb -h lists all the variables supported on the PC side and ANDROID_PRINTF_LOG is not among them.
Anybody out there know how to copy/export just the "Message" portion of the logcat output either from Eclipse or attached via the command line? I often need to just export the logging statements without all the timestamp, pid, and tag information as well. For example:
02-25 12:35:13.083: INFO/System.out(2272): URL Requested: http://...
I don't need or want the 02-25 12:35:13.083: INFO/System.out(2272): portion. Seems like I shouldn't have to write a script to post-process the output, either.
Been driving me nuts for awhile now, thanks!
Run logcat from a decent shell environment (linux, osx, cygwin or msys or in a pinch use the adb shell on the device itself), and pipe it into awk or sed, probably after grepping for the category of message and PID you care about.