In package com.caseyjbrooks.clog

public class Clog extends Object

Fields

public static final String KEY_V
public static final String KEY_D
public static final String KEY_I
public static final String KEY_W
public static final String KEY_E
public static final String KEY_WTF

Constructors

public Clog()
Parameters:
  • No parameters

Methods

public static ClogProfile getInstance()

Get the instance of Clog to log to. If the instance is defined, use that profile, otherwise create a new default profile.

Parameters:
  • No parameters
public static String getStackTraceString(Throwable tr)

Handy function to get a loggable stack trace from a Throwable. Copied from the Android Open Source Project Log.java class.

Parameters:
  • Throwable tr

    An exception to log

public static String format(String message, Object args)
Parameters:
  • String message
  • Object args
public static ClogProfile tag(String tag)
Parameters:
  • String tag
public static ClogProfile noTag()
Parameters:
  • No parameters
public static int logger(String logger, Throwable throwable)

Log a Throwable to a generic logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String logger

    the key of the logger to use

  • Throwable throwable

    the throwable to log

public static int logger(String logger, String message, Object args)

Log a formatted message to a generic logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String logger

    the key of the logger to use

  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int logger(String logger, String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to a generic logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String logger

    the key of the logger to use

  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int log(Throwable throwable)

Log a Throwable to the default logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int log(String message, Object args)

Log a formatted message to the default logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int log(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the default logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int v(Throwable throwable)

Log a Throwable to the 'verbose' logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int v(String message, Object args)

Log a formatted message to the 'verbose' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int v(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the 'verbose' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int d(Throwable throwable)

Log a Throwable to the 'debug' logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int d(String message, Object args)

Log a formatted message to the 'debug' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int d(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the 'debug' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int i(Throwable throwable)

Log a Throwable to the 'info' logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int i(String message, Object args)

Log a formatted message to the 'info' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int i(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the 'info' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int w(Throwable throwable)

Log a Throwable to the 'warning' logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int w(String message, Object args)

Log a formatted message to the 'warning' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int w(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the 'warning' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int e(Throwable throwable)

Log a Throwable to the 'error' logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int e(String message, Object args)

Log a formatted message to the 'error' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int e(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the 'error' logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static int wtf(Throwable throwable)

Log a Throwable to the WTF (what a terrible failure!) logger. Will print the stack trace of the throwable as the log message, and use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • Throwable throwable

    the throwable to log

public static int wtf(String message, Object args)

Log a formatted message to the WTF (what a terrible failure!) logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Object args

    (optional) the arguments to pass to the formatter

public static int wtf(String message, Throwable throwable, Object args)

Log a formatted message and a Throwable to the WTF (what a terrible failure!) logger. Will use the default tag, which if not specified will be the calling class's simple name.

Parameters:
  • String message

    the message to log. Should be marked up with your chosen formatter's markup, with objects passed in as varargs

  • Throwable throwable

    the throwable to log

  • Object args

    (optional) the arguments to pass to the formatter

public static void addProfile(String key, ProfileSupplier clog)

Add a new Clog profile named 'key'

Parameters:
public static void removeProfile(String key)

Remove the profile at 'key'

Parameters:
  • String key

    the key of the profile to remove

public static ClogProfile setCurrentProfile(String key)

Keys the current profile to the one named 'key'

Parameters:
  • String key

    the key of the profile to use

public static ClogProfile setCurrentProfile(String key, ProfileSupplier clog)

Add a new Clog profile named 'key', and then switches to that profile

Parameters:
public static Map<String, ClogProfile> getProfiles()

Returns all currently configured profiles

Parameters:
  • No parameters
public static void setAllProfiles(Map<String, ClogProfile> profiles)

Set all profiles

Parameters:
  • Map<String, ClogProfile> profiles

    the profile set to use