Class Log

java.lang.Object
com.castlabs.logutils.Log

public class Log extends Object
Custom logger class.

Allows filtering logs by level with the setLogLevel(int) method.

You can also register your own Log.Loggers to get the log messages.

Since:
4.2.0
  • Field Details

    • DEFAULT_LOG_LEVEL

      public static final int DEFAULT_LOG_LEVEL
      Default log level
      See Also:
  • Method Details

    • addLogger

      public static void addLogger(Log.Logger logger)
      Add a Log.Logger to receive logging messages.
      Parameters:
      logger - logger to add
    • removeLogger

      public static boolean removeLogger(Log.Logger logger)
      Removes a previously registered Log.Logger
      Parameters:
      logger - the logger to remove
      Returns:
      true if removed
    • getLogLevel

      public static int getLogLevel()
      Returns the current log level
      Returns:
      the current log level
    • setLogLevel

      public static void setLogLevel(int logLevel)
      Sets the log level.

      Any messages with the selected log level or higher will be logged.

      NOTE: The Log.Loggers will be called regardless of this log level.

      Parameters:
      logLevel - the log level to set
    • v

      public static int v(String tag, String msg)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • v

      public static int v(String tag, String msg, Throwable tr)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • d

      public static int d(String tag, String msg)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • d

      public static int d(String tag, String msg, Throwable tr)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • i

      public static int i(String tag, String msg)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • i

      public static int i(String tag, String msg, Throwable tr)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • e

      public static int e(String tag, String msg)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • e

      public static int e(String tag, String msg, Throwable tr)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • w

      public static int w(String tag, String msg)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)
    • w

      public static int w(String tag, String msg, Throwable tr)
      Send a Log.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:
      number of bytes written by Log.println(int, String, String)