Traces during Android development

-1

I want to enter layout messages during the development of an app in Android so that they appear in the message panel Run when launching the emulator, as if doing pe a System.out.println( "xxx" ); with JAVASE and be able to see a bit where the execution goes.

I wanted to use the Trace class, but it requires the API level 18 and I'm using the 16 .

    
asked by Orici 24.11.2016 в 23:15
source

2 answers

0

One of the most useful techniques when debugging and / or tracking applications on any platform is the creation of execution logs. Android of course is not far behind and also provides us with its own service and logging API through the class android.util.Log.

In Android, all log messages will be associated with the following information:

Date / Time of the message. Criticity Level of message severity (detailed below). PID Internal code of the process that has entered the message. Tag. Identification label of the message (it is detailed later). Message. The full text of the message. Similar to what happens with other logging frameworks, in Android the log messages will be classified by their criticality, thus existing several categories (ordered from highest to lowest criticality):

Error Warning Info Debug Verbose For each of these message types, there is an independent static method that allows adding it to the application's log. Thus, for each of the previous categories we have available the methods e (), w (), i (), d () and v () respectively.

public class LogsAndroid extends Activity {

private static final String LOGTAG = "LogsAndroid";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Log.e(LOGTAG, "Mensaje de error");
    Log.w(LOGTAG, "Mensaje de warning");
    Log.i(LOGTAG, "Mensaje de información");
    Log.d(LOGTAG, "Mensaje de depuración");
    Log.v(LOGTAG, "Mensaje de verbose");
}

}

I got the information from the following link:

link

I hope it serves you. Greetings.

    
answered by 24.11.2016 в 23:27
0

This is for the LogCat , within your Android Monitor you can filter the messages configured by priority

what they are:

V — Verbose (más baja prioridad)
D — Debug
I — Info
W — Warning
E — Error
A — Assert

To these messages you can configure a label and the message or data that you want to monitor, for example, we define 2 messages type Debug at the beginning and at the end of an application:

   Log.d("MiApp", "inicia mi aplicación :" + System.currentTimeMillis());

and

  Log.d("MiApp", "termino mi aplicación " + System.currentTimeMillis());

When you normally run your application and check the LogCat you can see various messages:

but if we filter them by the "MyApp" tag we can quickly locate the information we need:

you can even filter them by the defined text:

More information:

link

link

link

link

    
answered by 24.11.2016 в 23:39