Package com.castlabs.logutils

# 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.Logger`s to get the log messages.

Since:
  4.2.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `Log.Logger`
  Logger interface that receives logging messages.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `DEFAULT_LOG_LEVEL`
  Default log level

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `addLogger(Log.Logger logger)`
  Add a `Log.Logger` to receive logging messages.
  `static int`
  `d(String tag, String msg)`
  Send a `Log.DEBUG` log message.
  `static int`
  `d(String tag, String msg, Throwable tr)`
  Send a `Log.DEBUG` log message and log the exception.
  `static int`
  `e(String tag, String msg)`
  Send a `Log.ERROR` log message.
  `static int`
  `e(String tag, String msg, Throwable tr)`
  Send a `Log.ERROR` log message and log the exception.
  `static int`
  `getLogLevel()`
  Returns the current log level
  `static int`
  `i(String tag, String msg)`
  Send a `Log.INFO` log message.
  `static int`
  `i(String tag, String msg, Throwable tr)`
  Send a `Log.INFO` log message and log the exception.
  `static boolean`
  `removeLogger(Log.Logger logger)`
  Removes a previously registered `Log.Logger`
  `static void`
  `setLogLevel(int logLevel)`
  Sets the log level.
  `static int`
  `v(String tag, String msg)`
  Send a `Log.VERBOSE` log message.
  `static int`
  `v(String tag, String msg, Throwable tr)`
  Send a `Log.VERBOSE` log message and log the exception.
  `static int`
  `w(String tag, String msg)`
  Send a `Log.WARN` log message.
  `static int`
  `w(String tag, String msg, Throwable tr)`
  Send a `Log.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`

- ## Field Details

  - ### DEFAULT_LOG_LEVEL

    public static final int DEFAULT_LOG_LEVEL
    Default log level
    See Also:
      - Constant Field Values

- ## 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.Logger`s 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)`