Unable to view log info in LogCat with Android app

Started by
4 comments, last by howie_007 8 years, 5 months ago

I'm trying to send log messages so that I can see the output in LogCat via Eclipse. I tried it with the Android and SDL call but nothing shows up in Log Cat. I set the filter to "verbos" or "debug" but none of the information is displayed.

Is there a trick to this or am I doing something wrong.

Had to apply a fix to Eclipse so that it would show all the LogCat tabs so I do see all the info.


void CStatCounter::IncCycle( SDL_Window * m_pWindow )
{
    // These counters are incremeented each game loop cycle so they can
    // be placed here in this function because this function is also called
    // each game loop cycle
    m_elapsedFPSCounter += CHighResTimer::Instance().GetFPS();

    ++m_cycleCounter;

    // update the stats every 500 miliseconds
    if( m_statsDisplayTimer.Expired(CTimer::RESTART_ON_EXPIRE) )
    {
        // Show the output
        #if defined(__ANDROID__)
    	__android_log_print(ANDROID_LOG_DEBUG, "Lap Cat Games", "%s", "Test Message");
        #else
        if( !CSettings::Instance().GetFullScreen() )
            SDL_SetWindowTitle( m_pWindow, GetStatString().c_str() );
        #endif

        // Now that the stats are displayed, we can reset out counters.
        ResetCounters();
    }

}   // HasCycleCompleted

or


void CStatCounter::IncCycle( SDL_Window * m_pWindow )
{
    // These counters are incremeented each game loop cycle so they can
    // be placed here in this function because this function is also called
    // each game loop cycle
    m_elapsedFPSCounter += CHighResTimer::Instance().GetFPS();

    ++m_cycleCounter;

    // update the stats every 500 miliseconds
    if( m_statsDisplayTimer.Expired(CTimer::RESTART_ON_EXPIRE) )
    {
        // Show the output
        #if defined(__IPHONEOS__) || defined(__ANDROID__)
        SDL_LogDebug( SDL_LOG_CATEGORY_RENDER, "%s", GetStatString().c_str() );
        #else
        if( !CSettings::Instance().GetFullScreen() )
            SDL_SetWindowTitle( m_pWindow, GetStatString().c_str() );
        #endif

        // Now that the stats are displayed, we can reset out counters.
        ResetCounters();
    }

}   // HasCycleCompleted
Advertisement

I tried messing with it again and now the __android_log_print is working. these tools...

The logcat window in Eclipse is... not very good...

I always use "adb logcat" in a terminal instead, piped through a grep regexp to filter out the interesting stuff in the flood of nonsense.

Much more reliable.

The logcat window in Eclipse is... not very good...

I always use "adb logcat" in a terminal instead


Agreed here, adb logcat is the easiest way to go

He is right about all the nonsense / fluff in the logs. In my setup, unfortunately, I have 2 logcat windows running.
One that has everything logcat spits out (errors, opengl errors, segfaults, and etc) and the other window shows the messages with the tag I'm using (__android_log_print error, verbose, debug, and etc)

grep regexp to filter out the interesting stuff in the flood of nonsense.


Im interested in what are you greping on? I wonder if windows (my dev environment) can do the same with find / findstr.

Do your logs pull back everything for your application like what Android Studio would do? Pull back all the messages that come out of the application.

It's nothing special, just looks for the tags I use, plus some system ones that have been useful and not too spammy. ("DEBUG" and "ActivityManager")

Put into a shell script in my project dir.

looks like this:

adb logcat | grep -E I\/DEBUG\|jni\/\|W\/ActivityManager\|JNI\|\/FU\|GLView

It's far from perfect...

Then I have a "logcat-pid" script which just grep for a process id I provide as argument, to see if I missed something in the first one...

If I'm still scratching my head, its over to the full logcat pasted into a text editor...

Thanks for all the info!

This topic is closed to new replies.

Advertisement