Package android.util

Class Log


  • public final class Log
    extends java.lang.Object
    Mock Log implementation that writes to the console when testing on non android host.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ASSERT
      Priority constant for the println method.
      static int DEBUG
      Priority constant for the println method; use Log.d.
      static int ERROR
      Priority constant for the println method; use Log.e.
      static int INFO
      Priority constant for the println method; use Log.i.
      static int LOG_ID_CRASH  
      static int LOG_ID_EVENTS  
      static int LOG_ID_MAIN  
      static int LOG_ID_RADIO  
      static int LOG_ID_SYSTEM  
      static int VERBOSE
      Priority constant for the println method; use Log.v.
      static int WARN
      Priority constant for the println method; use Log.w.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int d​(java.lang.String tag, java.lang.String msg)
      Send a DEBUG log message.
      static int d​(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
      Send a DEBUG log message and log the exception.
      static int e​(java.lang.String tag, java.lang.String msg)
      Send an ERROR log message.
      static int e​(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
      Send a ERROR log message and log the exception.
      static java.lang.String getStackTraceString​(java.lang.Throwable tr)
      Handy function to get a loggable stack trace from a Throwable
      static int i​(java.lang.String tag, java.lang.String msg)
      Send an INFO log message.
      static int i​(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
      Send a INFO log message and log the exception.
      static boolean isLoggable​(java.lang.String tag, int level)
      Checks to see whether or not a log for the specified tag is loggable at the specified level.
      static int println​(int bufID, int priority, java.lang.String tag, java.lang.String msg)
      Print log message to the console.
      static int println​(int priority, java.lang.String tag, java.lang.String msg)
      Low-level logging call.
      static int v​(java.lang.String tag, java.lang.String msg)
      Send a VERBOSE log message.
      static int v​(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
      Send a VERBOSE log message and log the exception.
      static int w​(java.lang.String tag, java.lang.String msg)
      Send a WARN log message.
      static int w​(java.lang.String tag, java.lang.String msg, java.lang.Throwable tr)
      Send a WARN log message and log the exception.
      static int w​(java.lang.String tag, java.lang.Throwable tr)
      Send a WARN log message and log the exception.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isLoggable

        public static boolean isLoggable​(java.lang.String tag,
                                         int level)
        Checks to see whether or not a log for the specified tag is loggable at the specified level. This method always return true since the Log type is used for mocking.
        Parameters:
        tag - The tag to check. This value may be null.
        level - The level to check.
        Returns:
        true
      • v

        public static int v​(java.lang.String tag,
                            java.lang.String msg)
        Send a VERBOSE log message.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        Returns:
        returns 0.
      • v

        public static int v​(java.lang.String tag,
                            java.lang.String msg,
                            java.lang.Throwable tr)
        Send a VERBOSE log message and log the exception.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        tr - An exception to log
        Returns:
        returns 0.
      • d

        public static int d​(java.lang.String tag,
                            java.lang.String msg)
        Send a DEBUG log message.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        Returns:
        returns 0.
      • d

        public static int d​(java.lang.String tag,
                            java.lang.String msg,
                            java.lang.Throwable tr)
        Send a DEBUG log message and log the exception.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        tr - An exception to log.
        Returns:
        returns 0.
      • i

        public static int i​(java.lang.String tag,
                            java.lang.String msg)
        Send an INFO log message.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        Returns:
        returns 0.
      • i

        public static int i​(java.lang.String tag,
                            java.lang.String msg,
                            java.lang.Throwable tr)
        Send a INFO log message and log the exception.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        tr - An exception to log.
        Returns:
        returns 0.
      • w

        public static int w​(java.lang.String tag,
                            java.lang.String msg)
        Send a WARN log message.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        Returns:
        returns 0.
      • w

        public static int w​(java.lang.String tag,
                            java.lang.String msg,
                            java.lang.Throwable tr)
        Send a WARN log message and log the exception.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        tr - An exception to log.
        Returns:
        returns 0.
      • w

        public static int w​(java.lang.String tag,
                            java.lang.Throwable tr)
        Send a WARN log message and log the exception.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        tr - An exception to log.
        Returns:
        returns 0.
      • e

        public static int e​(java.lang.String tag,
                            java.lang.String msg)
        Send an ERROR log message.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        Returns:
        returns 0.
      • e

        public static int e​(java.lang.String tag,
                            java.lang.String msg,
                            java.lang.Throwable tr)
        Send a ERROR log message and log the exception.
        Parameters:
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        tr - An exception to log.
        Returns:
        returns 0.
      • getStackTraceString

        public static java.lang.String getStackTraceString​(java.lang.Throwable tr)
        Handy function to get a loggable stack trace from a Throwable
        Parameters:
        tr - An exception to log.
        Returns:
        The stack trace.
      • println

        public static int println​(int priority,
                                  java.lang.String tag,
                                  java.lang.String msg)
        Low-level logging call.
        Parameters:
        priority - The priority/type of this log message
        tag - Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        msg - The message you would like logged.
        Returns:
        The number of bytes written.
      • println

        public static int println​(int bufID,
                                  int priority,
                                  java.lang.String tag,
                                  java.lang.String msg)
        Print log message to the console.
        Parameters:
        bufID - The buffer id.
        priority - The priority of the log entry.
        tag - The tag.
        msg - The log message
        Returns:
        returns 0.