Package org.robolectric.shadows
Class ShadowLog
java.lang.Object
org.robolectric.shadows.ShadowLog
Controls the behavior of
Log and provides access to log messages.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clear all accumulated logs.protected static intprotected static intprotected static intprotected static intstatic 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 intprotected static intprotected static booleanisLoggable(String tag, int level) protected static charlevelToChar(int level) protected static intprintln_native(int bufID, int priority, String tag, String msg) static voidreset()static voidsetCaptureLogsEnabled(boolean isEnabled) By default this Shadow will capture all logs in memory in order to facilitate thegetLogs()andgetLogsForTag(String)APIs.static voidsetLoggable(String tag, int level) Sets the log level of a given tag, thatisLoggable(java.lang.String, int)will follow.static voidsetTimeSupplier(Supplier<String> supplier) Sets supplier that can be used to get time to add to logs.static voidstatic voidsetWtfIsFatal(boolean fatal) Sets whether callingLog.wtf(java.lang.String, java.lang.String)will throwLog.TerribleFailure.protected static intprotected static intprotected static intprotected static intprotected static intprotected static intprotected static int
-
Field Details
-
stream
-
-
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 throwLog.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) -
setCaptureLogsEnabled
public static void setCaptureLogsEnabled(boolean isEnabled) By default this Shadow will capture all logs in memory in order to facilitate thegetLogs()andgetLogsForTag(String)APIs. This is wasteful if these APIs are not actually used by tests.This API allows disabling this behavior.
If log capturing is disabled,
getLogs()andgetLogsForTag(String)will throw if called.- Parameters:
isEnabled-
-
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()
-