Package org.robolectric.shadows
Class ShadowLog
java.lang.Object
org.robolectric.shadows.ShadowLog
@Implements(android.util.Log.class) public class ShadowLog extends Object
Controls the behavior of
Log
and provides access to log messages.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowLog.LogItem
A single log item.static class
ShadowLog.TerribleFailure
Failure thrown when wtf_is_fatal is true and Log.wtf is called. -
Field Summary
Fields Modifier and Type Field Description static PrintStream
stream
-
Constructor Summary
Constructors Constructor Description ShadowLog()
-
Method Summary
Modifier and Type Method Description static void
clear()
Clear all accumulated logs.protected static int
d(String tag, String msg)
protected static int
d(String tag, String msg, Throwable throwable)
protected static int
e(String tag, String msg)
protected static int
e(String tag, String msg, Throwable throwable)
static com.google.common.collect.ImmutableList<ShadowLog.LogItem>
getLogs()
Returns ordered list of all log entries.static com.google.common.collect.ImmutableList<ShadowLog.LogItem>
getLogsForTag(String tag)
Returns ordered list of all log items for a specific tag.protected static int
i(String tag, String msg)
protected static int
i(String tag, String msg, Throwable throwable)
protected static boolean
isLoggable(String tag, int level)
protected static char
levelToChar(int level)
protected static int
println_native(int bufID, int priority, String tag, String msg)
static void
reset()
static void
setLoggable(String tag, int level)
Sets the log level of a given tag, thatisLoggable(java.lang.String, int)
will follow.static void
setTimeSupplier(Supplier<String> supplier)
Sets supplier that can be used to get time to add to logs.static void
setupLogging()
static void
setWtfIsFatal(boolean fatal)
Sets whether callingLog.wtf(java.lang.String, java.lang.String)
will throwShadowLog.TerribleFailure
.protected static int
v(String tag, String msg)
protected static int
v(String tag, String msg, Throwable throwable)
protected static int
w(String tag, String msg)
protected static int
w(String tag, String msg, Throwable throwable)
protected static int
w(String tag, Throwable throwable)
protected static int
wtf(String tag, String msg)
protected static int
wtf(String tag, String msg, Throwable throwable)
-
Field Details
-
Constructor Details
-
ShadowLog
public ShadowLog()
-
-
Method Details
-
e
-
e
-
d
-
d
-
i
-
i
-
v
-
v
-
w
-
w
-
w
-
wtf
-
wtf
-
setWtfIsFatal
public static void setWtfIsFatal(boolean fatal)Sets whether callingLog.wtf(java.lang.String, java.lang.String)
will throwShadowLog.TerribleFailure
. -
setTimeSupplier
Sets supplier that can be used to get time to add to logs. -
isLoggable
-
println_native
@Implementation protected static int println_native(int bufID, int priority, String tag, String msg) -
setLoggable
Sets the log level of a given tag, thatisLoggable(java.lang.String, int)
will follow.- Parameters:
tag
- A log taglevel
- A log level, fromLog
-
levelToChar
protected static char levelToChar(int level) -
getLogs
Returns ordered list of all log entries.- Returns:
- List of log items
-
getLogsForTag
Returns ordered list of all log items for a specific tag.- Parameters:
tag
- The tag to get logs for- Returns:
- The list of log items for the tag or an empty list if no logs for that tag exist.
-
clear
public static void clear()Clear all accumulated logs. -
reset
-
setupLogging
public static void setupLogging()
-