I want to add some log in fall.rs (in:packages\wallpapers\Basic\src\com\android\wallpaper\fall). And the code is like this:
int root(void) {
rsDebug("===========root==================",0);
rsgClearColor(0.f, 0.f, 0.f, 1.f);
...
}
But my device can't print any log when I set live wallpaper. Although there are many examples about "rsDebug", but I can't find what's wrong when I use "rsDebug".
What kind of device is this (and what version of Android is it running)? Also, rsDebug logs at the "D" (Debug) level, so if you are filtering logcat, you might just not be seeing it. Do you see any messages tagged as "D"?
To see all renderscript debug messages from logcat, use:
adb logcat -s RenderScript:D
To filter for your specific application, add a prefix in the rsDebug message:
rsDebug("==MyApplication== my debug message", 0);
and filter in logcat:
adb logcat -s RenderScript:D | grep ==MyApplication==
Related
did anyone notice that on Android - Ti SDK 5.4.0.GA is showing many output at console on all modes like Trace, Debug, Info, Warning, Error.
I have not tried it for Wi-Fi off state, but it is showing such lines every second when the device is connected to Wi-Fi and my console filled up with 100 lines in just few seconds:
[INFO] : D/StatusBar.MSimNetworkController( 1166): getNumberOfActiveSim:0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getPhoneSignalIconList: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0
[INFO] : D/StatusBar.MSimNetworkController( 1166): getDataSignalIconId: mMaxLevelOfSignalStrengthIndicator = 4 inetCondition = 0 iconLevel = 4
[INFO] : D/StatusBar.MSimNetworkController( 1166): updateTelephonySignalStrength: iconLevel=4
Can anyone suggest any solution as this is getting quite annoying and I cannot focus on the console output from code due to too many above logs?
Update
Finally I found a solution to this problem:
https://github.com/appcelerator/titanium_mobile/pull/8754
Logs that contain a dot (or any other character besides letters) won't be caught in the don't show part!
The PR will change the RegEx rule to match any character.
Old solution:
Check the output of ti config cli.logLevel and set it to info
Might solve the problem for you.
I'm facing the same issue and I use monitor with this custom filter:
^(?!(WifiStateMachine|WIFI_UT|AppOps|GraphicsStats|RegisteredNfcid2Cache|Wifi|NotifUtils|WIFI|usbnet|Ethernet|FaceDetectTask|RecentsTaskLoadPlan|MorningBundlePlugin|SocialManagerService|PhoneApp|LoadDialerReceiver|Icing|Herrevad|Finsky|StatusBarManagerService|DropBoxEntryAddedChimeraService|ClearcutLoggerApiImpl|AlarmManager|GCoreUlr|GCoreFlp|APSAnalyticsService|QCNEJ|NetworkStats|IpReachabilityMonitor|Nfcid2RoutingManager|ls|WifiManager|libc|dex2oat|ACRA|HtcMirrorLinkAmsListener|LOWI-Scan|DownloadManagerWrapper|wpa_supplicant|QCALOG|WIFI_ICON|HtcWrapCustomizationManager|gdlights|PowerUtils|ExtremePowerSave|WifiService|FrameworkListener|MediaRouterServie|DotMatrix|PowerUI|PMS|XTCC-5.1.0.7|NetworkManagement|HtcPowerSaver|BatteryControlle|NetLinkSocketObs|WifiController|NetlinkSocketObs|BatteryService|UsbnetService|DeviceIdleControler|Keyboard.Facilit|xiaomi|qdlights|SensorService|AutoSetting|HtcWifiRssiMonitor|HtcWifiDataStallTracker|WifiAutoJoinController|HtcWLD_v5.1.0|WifiMonitor|WifiConfigStore|StatusBar.NetworkController|CwMcuSensor|BrcmNfcJni|DATA_ICON|TelephoneCallback|ContactMessageStore|HtcUPManager|ScreenOnOffReceiver|DeviceIdleController|QSPanel|NetworkPolicy|GpsLocationProvider|SensorManager|SmartNS_PSService|PhoneStatusBar|ScrimController|Settings|LocationManagerService|getVisibilityByRssi|NetworkController.WifiSignalController|GAv4|IntegrityChecker|KernelCpuSpeedReader|KernelWakelockReader|BatteryStatsImpl|WeatherUtility|WeatherTimeKeeper|PNP_UPDATERD|DsService|PathParser|StatusBarManagerServiceHtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|HtcASN_1.1|SignalClusterView|SIGNAL_ICON|HtcSystemUPManager|ConnectivityService|WSP|Babel|CityCodeHelper|TetherStatsReporting|TelephonyCallback))
Put this in by Log Tag in a new filter. My device is a HTC A9, a very log-noisy device!
If you still see rows you don't want to just put attach the tags with |tagname
I am trying to run some GMock/GTest tests on Android. These all run fine, but there's no output, as GMock logs to stdout.
I've tried the following with no luck (likely because it's for the Dalvik VM, and they've done away with that in Android 5):
$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start
When log.redirect-stdio is set to true, there is still no output from stdio to logcat.
I've also tried custom several streambuf implementations with std::cout.rdbuf to try to direct stdout to logcat with __android_log_print, but none of these have printed anything to logcat.
Has anyone successfully managed to redirect stdout to logcat in Android 5?
I can add more details (such as streambuf implementations I've tried) if needed.
This isn't really a solution to the problem of redirecting stdout to logcat, but I'm suggesting it as a workaround in case it helps someone.
You can redirect stdout to a file instead:
freopen("/data/data/com.your.package/files/out.txt", "w", stdout);
... // Call GMock which prints to the file instead
fclose(stdout)
We can then cat the file to see the logged test results. Sadly Android doesn't have tail so the logging isn't nicely available in real time. (Unless you're good at spamming cat)
Do it with the old Java way: (but I am using kotlin, can anyone suggest a cleaner version?)
documentation: System.setOut()
import java.io.OutputStream
import java.io.PrintStream
private const val TAG = "MyActivity"
class LogcatOutputStream: OutputStream(){
private var line_buffer: StringBuilder = StringBuilder()
override fun write(b: Int){
when(b){
'\n'.toInt() -> {
Log.i(TAG, line_buffer.toString())
line_buffer.setLength(0)
}
else -> line_buffer.append(b.toChar())
}
}
}
// put this somewhere in the code, like onCreate() as shown
class MainActivity: Activity(){
override fun onCreate(savedInstanceState: Bundle?){
// some other code
PrintStream(LoggerOutputStream()).let{
System.setOut(it)
System.setErr(it)
}
// some other code
}
}
// result:
println("Hello World") // which is effectively System.out.println in Java
// with have the below output in logcat
I/MyActivity(<pid>): Hello World
// as a reminder, you can filter logcat by tags
adb logcat MyActivity:D
// to only show logs tagged with 'MyActivity' (same value as 'TAG' above)
On Linux systems I've used 'export GST_DEBUG=<#>' to debug problems with a program's use of GStreamer. I'm now working on Android and would like to do the same - see the GStreamer output included in the logcat output.
I have a Google Nexus 5 phone and I'm using the full_hammerhead_userdebug build. I've seen the following suggested:
Add the following in JNI_OnLoad:
setenv("GST_DEBUG", "*:5", 1);
setenv("GST_DEBUG_NO_COLOR", "1", 1);
Unfortunately I'm trying to debug a C library, so I would prefer to set something in the environment to enable the debug output. I tried to add the following lines to build.prop:
export GST_DEBUG=3
GST_DEBUG=3
log.redirect-stdio=true
That didn't work. Either I'm not enabling GST_DEBUG properly or I'm not redirecting it properly. Or I'm way off track and I should be doing something else. How can I enable GST_DEBUG with Android?
P.S. This question is similar to one, but that one didn't completely answer my question.
I ended up going in another direction to solve this problem. First I created my own GstLogFunction()
void gstAndroidLog(GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
GstDebugMessage * message,
gpointer data)
{
if (level <= gst_debug_category_get_threshold (category))
{
__android_log_print(ANDROID_LOG_ERROR, "MY_APP", "%s,%s: %s",
file, function, gst_debug_message_get(message));
}
}
Then after gst_init() is called, I set up the log levels. If I want to see everything, I can set:
gst_debug_set_default_threshold( GST_LEVEL_DEBUG );
If I just want to see what is happening in a specific category, I can set:
gst_debug_set_threshold_for_name ("tcpclientsink", GST_LEVEL_LOG);
Then I just need to register the log function I created:
gst_debug_add_log_function(&gstAndroidLog, NULL);
My goal is to add a single printk command to one of the driver files for my phone's touchscreen. I would like to run this printk command everytime the screen recieves touch input. I found the list of touchscreen driver files shown below. I'm just hoping someone with some experience might be able to point me to the correct file to place this printk command.
ad7877.c atmel_224e.c cy8ctmg110_ts.c gunze.c intel-mid-touch.c
max11801_ts.c pcap_ts.c touchit213.c ucb1400_ts.c wm9712.c
ad7879.c atmel_mxt_ts.c da9034-ts.c h3600_ts_input.c jornada720_ts.c
mc13783_ts.c penmount.c touchright.c usbtouchscreen.c wm9713.c
ad7879.h atmel_tsadcc.c dynapro.c hampshire.c Kconfig
mcs5000_ts.c s3c2410_ts.c touchwin.c w90p910_ts.c wm97xx-core.c
ad7879-i2c.c atmel-wm97xx.c eeti_ts.c hp680_ts_input.c lpc32xx_ts.c
migor_ts.c st1232.c tps6507x-ts.c wacom_w8001.c zylonite-wm97xx.c
ad7879-spi.c bu21013_ts.c elo.c htcpen.c mainstone-wm97xx.c
mk712.c stmpe-ts.c tsc2005.c wm831x-ts.c
First Check the Driver file by using the following command on terminal:
$logcat | grep EventHub
You will find all the input devices (Including your touch driver) in the prints.
Go to that file and add the print command in interrupt handler.
Try running the getevent command in a shell on the Android device. The touchscreen should be listed, and the name should be the driver being used.
Here's what came up on my phone:
add device 7: /dev/input/event1
name: "synaptics_dsx"
This means my phone uses the synaptics_dsx touchscreen driver.
In an android app I am trying to get my application log messages and saving them to file
I am using the code below.
I am using a different TAG for each of my class and there are several of them.
doing logcat -d gives me all irrelevant messages..
putting my package name like
logcat -d myapp.com:I *:S
does not work the results are empty but if I do
logcat -d MYCLASS1TAG:I MYCLASS2TAG *:S
then it works, but I have many classes..
how can I just put my package name and get results ..??
try {
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null)
{
// write to my file here
}
} catch (IOException e) { }
I'm not sure how to do it from the command line, but the ADT plugin for Eclipse lets you filter by application.
edit: I was curious, so I looked through the ADT source to figure out how ADT does it. The long and short of it is that it uses the -v long option to include the PID with each message, and it keeps a Map from a PID to an app name. The relevant source code files are in the package com.android.ddmuilib.logcat.LogCatMessageParser and com.android.ddmuilib.logcat.LogCatPidToNameMapper.
So, one workaround I can think of is to call up a shell (adb shell), figure out your PID using ps, and then pipe the output of adb logcat to grep:
adb logcat -v long | grep <your PID>
It will be a bit of a pain since your PID will change every time you run the app, but that's how you can do it in a pinch.
edit: I just noticed that the long format actually prints the PID on one line and the message on the next line, so you may need to use something like awk instead of grep. I'll test a few things out and post a followup.
So as I understand it you are trying to run logcat on the device to grab and save to file. Unfortunately in the current command line the filterspec only supports the tag:priority format. You will need to run the output through your own line by line filter. You can probably automate this by figuring out your PID and then filtering lines based on that.