This series of IoT App development notes are the learning notes of station B video tutorials, video address:

  • Day1 How does Android project code work
  • Day2 Common controls and interface layout design (part 1)
  • Day3 Common controls and interface layout design (part 2)
  • Day4 Import of MQTT Jar package and debugging of Internet of Things
  • Day5 APP practical control of Internet of Things ESP8266
  • 【7 days Java0 basic Crash Android development 】
  • [7-day Java0 Basic Rapid Android Development] Day7 achievement Demonstration

1. The Log tool in Android

The android.util.Log class provides five methods for developers to print Log information:

  • Log.v(): level verbose, lowest (4)
  • Log.d(): Prints debugging information, level debug, low (3)
  • Log.i(): Prints common information, level INFO, common (2)
  • Log.w(): Prints a warning message. The level is warning, high (1)
  • Log.e(): Prints an error message, level error, highest (0)

2. Use

The import package:

import android.util.Log;
Copy the code

Use:

        // Test log information is printed
        Log.v("MainActivity"."This is a verbose log!");
        Log.d("MainActivity"."This is a Debug log!");
        Log.i("MainActivity"."This is a Info log!");
        Log.w("MainActivity"."This is a Warning log!");
        Log.e("MainActivity"."This is a Error log!");
Copy the code



You can see it on the Android Studio console:



After filtering in Logcat, you can also see:

3. The TAG parameter is automatically generated

It would be too much trouble to enter the TAG argument every time. You can type logt outside the class method and press TAB to complete it automatically:



All you need to do is call TAG:

Welcome to subscribe to my wechat official account: “McUlover666”.