Package com.castlabs.utils
Class Log
- java.lang.Object
-
- com.castlabs.utils.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLog.LoggerLogger interface that receives logging messages.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_LOG_LEVELDefault log level
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddLogger(Log.Logger logger)Add aLog.Loggerto receive logging messages.static intd(String tag, String msg)Send aLog.DEBUGlog message.static intd(String tag, String msg, Throwable tr)Send aLog.DEBUGlog message and log the exception.static inte(String tag, String msg)Send aLog.ERRORlog message.static inte(String tag, String msg, Throwable tr)Send aLog.ERRORlog message and log the exception.static intgetLogLevel()Returns the current log levelstatic inti(String tag, String msg)Send aLog.INFOlog message.static inti(String tag, String msg, Throwable tr)Send aLog.INFOlog message and log the exception.static booleanremoveLogger(Log.Logger logger)Removes a previously registeredLog.Loggerstatic voidsetLogLevel(int logLevel)Sets the log level.static intv(String tag, String msg)Send aLog.VERBOSElog message.static intv(String tag, String msg, Throwable tr)Send aLog.VERBOSElog message and log the exception.static intw(String tag, String msg)Send aLog.WARNlog message.static intw(String tag, String msg, Throwable tr)Send aLog.WARNlog message and log the exception.
-
-
-
Field Detail
-
DEFAULT_LOG_LEVEL
public static final int DEFAULT_LOG_LEVEL
Default log level- See Also:
- Constant Field Values
-
-
Method Detail
-
addLogger
public static void addLogger(Log.Logger logger)
Add aLog.Loggerto receive logging messages.- Parameters:
logger- logger to add
-
removeLogger
public static boolean removeLogger(Log.Logger logger)
Removes a previously registeredLog.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 aLog.VERBOSElog 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 aLog.VERBOSElog 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 aLog.DEBUGlog 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 aLog.DEBUGlog 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 aLog.INFOlog 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 aLog.INFOlog 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 aLog.ERRORlog 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 aLog.ERRORlog 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 aLog.WARNlog 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 aLog.WARNlog 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)
-
-