Skip to content
senagbe edited this page May 28, 2012 · 6 revisions

This page presents the log methods provided by Androlog

Supported log levels and their associated methods

  • VERBOSE : Log.v
  • DEBUG : Log.d
  • INFO : Log.i
  • WARN : Log.w
  • ERROR : Log.e

Signatures

All the methods listed above supports different set of parameters:

  • (tag name, message : the tag name is a string object identifying the logger.
  • (tag name, message, exception : the tag name is a string object identifying the logger, exception is a Throwable object attached to the logged message.
  • (object, message) : the tag name is computed from the given object, so it use the qualified name of the given object. We generally use this.
  • (object, message, exception) : the tag name is computed from the given object, so it use the qualified name of the given object. We generally use this. Exception is a Throwable object attached to the logged message.
  • (message) : the tag name is computed from the current thread stack, so it uses the qualified name of the class logging the message as tag. This method is equivalent to (this, message).

Examples

package androlog.example;
import de.akquinet.android.androlog.Log;

public class AndrologExample {

    public void doSomething() {
        Log.i("my tag", "a logged message"); // Regular Android API
        Log.i(this, "a logged message"); // the tag will be androlog.example.AndrologExample
        Log.i("a logged message"); // the tag will be androlog.example.AndrologExample
    }

}

Note about (message) methods

The computation of the TAG from the current Thread stack is expensive as it requires an execution stack analysis.

Support of the 'What a Terrible Failure' methods.

Android 2.2 has introduced new log methods named wtf. Androlog provides methods delegating on those methods on Android 2.2. On prior versions, the message is logged using the ASSERT level. Those messages are always logged regardless the activation of the logger.

Note that the Android wtf methods may cause the application to terminate according to the system settings. To avoid this behavior, you can configure Androlog with androlog.delegate.wtf set to false.