Package backtraceio.library.breadcrumbs
Class BacktraceBreadcrumbs
- java.lang.Object
-
- backtraceio.library.breadcrumbs.BacktraceBreadcrumbs
-
- All Implemented Interfaces:
Breadcrumbs
public class BacktraceBreadcrumbs extends java.lang.Object implements Breadcrumbs
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_LOG_SIZE_BYTES
-
Constructor Summary
Constructors Constructor Description BacktraceBreadcrumbs(java.lang.String breadcrumbLogDirectory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddBreadcrumb(java.lang.String message)Add a breadcrumb of type "Manual" and level "Info" with the provided message stringbooleanaddBreadcrumb(java.lang.String message, BacktraceBreadcrumbLevel level)Add a breadcrumb of type "Manual" and the desired level with the provided message stringbooleanaddBreadcrumb(java.lang.String message, BacktraceBreadcrumbType type)Add a breadcrumb of the desired type and level "Info" with the provided message stringbooleanaddBreadcrumb(java.lang.String message, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level)Add a breadcrumb of the desired level and type with the provided message stringbooleanaddBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes)Add a breadcrumb of type "Manual" and level "Info" with the provided message string and attributesbooleanaddBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes, BacktraceBreadcrumbLevel level)Add a breadcrumb of type "Manual" and the desired level with the provided message string and attributesbooleanaddBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes, BacktraceBreadcrumbType type)Add a breadcrumb of the desired type and level "Info" with the provided message string and attributesbooleanaddBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level)Add a breadcrumb of the desired level and type with the provided message string and attributesbooleanclearBreadcrumbs()Clear breadcrumb logsbooleanenableBreadcrumbs(android.content.Context context)Enable logging of breadcrumbs and submission with crash reportsbooleanenableBreadcrumbs(android.content.Context context, int maxBreadcrumbLogSizeBytes)Enable logging of breadcrumbs and submission with crash reportsbooleanenableBreadcrumbs(android.content.Context context, java.util.EnumSet<BacktraceBreadcrumbType> breadcrumbTypesToEnable)Enable logging of breadcrumbs and submission with crash reportsbooleanenableBreadcrumbs(android.content.Context context, java.util.EnumSet<BacktraceBreadcrumbType> breadcrumbTypesToEnable, int maxBreadcrumbLogSizeBytes)Enable logging of breadcrumbs and submission with crash reportsjava.lang.StringgetBreadcrumbLogPath()Get the location of the breadcrumb loglonggetCurrentBreadcrumbId()Get the current breadcrumb ID (exclusive).java.util.EnumSet<BacktraceBreadcrumbType>getEnabledBreadcrumbTypes()Gets the enabled breadcrumb typesbooleanisEnabled()Determinate if Breadcrumbs are enabled.voidprocessReportBreadcrumbs(BacktraceReport backtraceReport)If Breadcrumbs is currently enabled, process the BacktraceReport for sending the Breadcrumb logsvoidsetCurrentBreadcrumbId(long breadcrumbId)NOTE: This should only be used for testingvoidsetOnSuccessfulBreadcrumbAddEventListener(OnSuccessfulBreadcrumbAddEventListener eventListener)Set event executed after adding a breadcrumb to the file
-
-
-
Field Detail
-
DEFAULT_MAX_LOG_SIZE_BYTES
public static final int DEFAULT_MAX_LOG_SIZE_BYTES
- See Also:
- Constant Field Values
-
-
Method Detail
-
setOnSuccessfulBreadcrumbAddEventListener
public void setOnSuccessfulBreadcrumbAddEventListener(OnSuccessfulBreadcrumbAddEventListener eventListener)
Set event executed after adding a breadcrumb to the file- Specified by:
setOnSuccessfulBreadcrumbAddEventListenerin interfaceBreadcrumbs- Parameters:
eventListener- object with method which will be executed
-
enableBreadcrumbs
public boolean enableBreadcrumbs(android.content.Context context)
Description copied from interface:BreadcrumbsEnable logging of breadcrumbs and submission with crash reports- Specified by:
enableBreadcrumbsin interfaceBreadcrumbs- Parameters:
context- context of current state of the application- Returns:
- true if we successfully enabled breadcrumbs
-
enableBreadcrumbs
public boolean enableBreadcrumbs(android.content.Context context, java.util.EnumSet<BacktraceBreadcrumbType> breadcrumbTypesToEnable)Description copied from interface:BreadcrumbsEnable logging of breadcrumbs and submission with crash reports- Specified by:
enableBreadcrumbsin interfaceBreadcrumbs- Parameters:
context- context of current state of the applicationbreadcrumbTypesToEnable- a set containing which breadcrumb types to enable- Returns:
- true if we successfully enabled breadcrumbs
-
enableBreadcrumbs
public boolean enableBreadcrumbs(android.content.Context context, int maxBreadcrumbLogSizeBytes)Description copied from interface:BreadcrumbsEnable logging of breadcrumbs and submission with crash reports- Specified by:
enableBreadcrumbsin interfaceBreadcrumbs- Parameters:
context- context of current state of the applicationmaxBreadcrumbLogSizeBytes- breadcrumb log size limit in bytes, should be a power of 2- Returns:
- true if we successfully enabled breadcrumbs
-
enableBreadcrumbs
public boolean enableBreadcrumbs(android.content.Context context, java.util.EnumSet<BacktraceBreadcrumbType> breadcrumbTypesToEnable, int maxBreadcrumbLogSizeBytes)Description copied from interface:BreadcrumbsEnable logging of breadcrumbs and submission with crash reports- Specified by:
enableBreadcrumbsin interfaceBreadcrumbs- Parameters:
context- context of current state of the applicationbreadcrumbTypesToEnable- a set containing which breadcrumb types to enablemaxBreadcrumbLogSizeBytes- breadcrumb log size limit in bytes, should be a power of 2- Returns:
- true if we successfully enabled breadcrumbs
-
getEnabledBreadcrumbTypes
public java.util.EnumSet<BacktraceBreadcrumbType> getEnabledBreadcrumbTypes()
Description copied from interface:BreadcrumbsGets the enabled breadcrumb types- Specified by:
getEnabledBreadcrumbTypesin interfaceBreadcrumbs- Returns:
- enabled breadcrumb types
-
clearBreadcrumbs
public boolean clearBreadcrumbs()
Description copied from interface:BreadcrumbsClear breadcrumb logs- Specified by:
clearBreadcrumbsin interfaceBreadcrumbs- Returns:
- true if log was successfully cleared
-
setCurrentBreadcrumbId
public void setCurrentBreadcrumbId(long breadcrumbId)
NOTE: This should only be used for testing- Specified by:
setCurrentBreadcrumbIdin interfaceBreadcrumbs- Parameters:
breadcrumbId- Will force set the current breadcrumb ID
-
getCurrentBreadcrumbId
public long getCurrentBreadcrumbId()
Get the current breadcrumb ID (exclusive). This is useful when breadcrumbs are queued and posted to an API because in the meantime before the breadcrumbs are finally posted we might get more breadcrumbs which are not relevant (because they occur after queueing up the breadcrumb sender). Therefore it is useful to mark the breadcrumb sender with the most current breadcrumb ID at the time of queuing up the request to post the breadcrumbs.- Specified by:
getCurrentBreadcrumbIdin interfaceBreadcrumbs- Returns:
- current breadcrumb ID (exclusive)
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message)
Add a breadcrumb of type "Manual" and level "Info" with the provided message string- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, BacktraceBreadcrumbLevel level)Add a breadcrumb of type "Manual" and the desired level with the provided message string- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-level-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes)Add a breadcrumb of type "Manual" and level "Info" with the provided message string and attributes- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-attributes-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes, BacktraceBreadcrumbLevel level)Add a breadcrumb of type "Manual" and the desired level with the provided message string and attributes- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-attributes-level-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, BacktraceBreadcrumbType type)Add a breadcrumb of the desired type and level "Info" with the provided message string- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-type-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level)Add a breadcrumb of the desired level and type with the provided message string- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-type-level-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes, BacktraceBreadcrumbType type)Add a breadcrumb of the desired type and level "Info" with the provided message string and attributes- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-attributes-type-- Returns:
- true if the breadcrumb was successfully added
-
addBreadcrumb
public boolean addBreadcrumb(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> attributes, BacktraceBreadcrumbType type, BacktraceBreadcrumbLevel level)Add a breadcrumb of the desired level and type with the provided message string and attributes- Specified by:
addBreadcrumbin interfaceBreadcrumbs- Parameters:
message-attributes-type-level-- Returns:
- true if the breadcrumb was successfully added
-
processReportBreadcrumbs
public void processReportBreadcrumbs(BacktraceReport backtraceReport)
If Breadcrumbs is currently enabled, process the BacktraceReport for sending the Breadcrumb logs- Specified by:
processReportBreadcrumbsin interfaceBreadcrumbs- Parameters:
backtraceReport-
-
isEnabled
public boolean isEnabled()
Determinate if Breadcrumbs are enabled.- Specified by:
isEnabledin interfaceBreadcrumbs- Returns:
- true if breadcrumbs are enabled.
-
getBreadcrumbLogPath
public java.lang.String getBreadcrumbLogPath()
Description copied from interface:BreadcrumbsGet the location of the breadcrumb log- Specified by:
getBreadcrumbLogPathin interfaceBreadcrumbs- Returns:
- Location of the breadcrumb log
-
-