Class Log


  • public class Log
    extends java.lang.Object
    A simple wrapper for Log that supports log message formatting and turning on or off logging based on tag.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  Log.Level
      The list of possible of logging levels.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEBUG
      The level for debug log messages.
      static int ERROR
      The level for error log messages.
      static int INFO
      The level for information log messages.
      static int VERBOSE
      The level for verbose log messages.
      static int WARN
      The level for warning log messages.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int d​(java.lang.String tag, java.lang.String message, java.lang.Object... arguments)
      Logs a debug message.
      static int d​(java.lang.String tag, java.lang.String message, java.lang.Throwable error, java.lang.Object... arguments)
      Logs a debug message.
      static int e​(java.lang.String tag, java.lang.String message, java.lang.Object... arguments)
      Logs an error message.
      static int e​(java.lang.String tag, java.lang.String message, java.lang.Throwable error, java.lang.Object... arguments)
      Logs an error message.
      static int i​(java.lang.String tag, java.lang.String message, java.lang.Object... arguments)
      Logs an information message.
      static int i​(java.lang.String tag, java.lang.String message, java.lang.Throwable error, java.lang.Object... arguments)
      Logs an information message.
      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 v​(java.lang.String tag, java.lang.String message, java.lang.Object... arguments)
      Logs a verbose message.
      static int v​(java.lang.String tag, java.lang.String message, java.lang.Throwable error, java.lang.Object... arguments)
      Logs a verbose message.
      static int w​(java.lang.String tag, java.lang.String message, java.lang.Object... arguments)
      Logs a warning message.
      static int w​(java.lang.String tag, java.lang.String message, java.lang.Throwable error, java.lang.Object... arguments)
      Logs a warning message.
      • 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​(@NonNull
                                         java.lang.String tag,
                                         int level)
        Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag should be logged. You can change the default level by setting a system property: 'setprop log.tag. ' Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all logging for your tag. You can also create a local.prop file that with the following in it: 'log.tag.=' and place that in /data/local.prop.
        Parameters:
        tag - The tag to check.
        level - The level to check.
        Returns:
        true if the tag this is allowed to be logged, otherwise false.
      • v

        public static int v​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Object... arguments)
        Logs a verbose message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • v

        public static int v​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Throwable error,
                            java.lang.Object... arguments)
        Logs a verbose message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        error - the error to be logged, if any.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • d

        public static int d​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Object... arguments)
        Logs a debug message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • d

        public static int d​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Throwable error,
                            java.lang.Object... arguments)
        Logs a debug message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        error - the error to be logged, if any.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • i

        public static int i​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Object... arguments)
        Logs an information message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • i

        public static int i​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Throwable error,
                            java.lang.Object... arguments)
        Logs an information message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        error - the error to be logged, if any.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • w

        public static int w​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Object... arguments)
        Logs a warning message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • w

        public static int w​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Throwable error,
                            java.lang.Object... arguments)
        Logs a warning message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        error - the error to be logged, if any.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • e

        public static int e​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Object... arguments)
        Logs an error message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.
      • e

        public static int e​(@NonNull
                            java.lang.String tag,
                            @NonNull
                            java.lang.String message,
                            java.lang.Throwable error,
                            java.lang.Object... arguments)
        Logs an error message.
        Parameters:
        tag - the string that will ssed to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
        message - the message to be logged. The message may contain formatting token supported by String.format(String, Object...) method.
        error - the error to be logged, if any.
        arguments - an array of objects to be used for formatting the log message.
        Returns:
        The number of bytes written.