Class ErrorLogHelper
- java.lang.Object
-
- com.microsoft.appcenter.crashes.utils.ErrorLogHelper
-
public class ErrorLogHelper extends java.lang.ObjectErrorLogHelper to help constructing, serializing, and de-serializing locally stored error logs.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEVICE_INFO_FILEDevice info filename.static java.lang.StringERROR_LOG_FILE_EXTENSIONError log file extension for the JSON schema.static intFRAME_LIMITFor huge stack traces such as giant StackOverflowError, we keep only beginning and end of frames according to this limit.static intMAX_PROPERTY_ITEM_LENGTHMax length of properties.static java.lang.StringMINIDUMP_FILE_EXTENSIONMinidump file extension for the NDK crashes.static java.lang.StringTHROWABLE_FILE_EXTENSIONError log file extension for the serialized throwable for client side inspection.
-
Constructor Summary
Constructors Constructor Description ErrorLogHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanPendingMinidumps()Clear (delete all content) pending minidump directory.static voidclearStaticState()static ManagedErrorLogcreateErrorLog(android.content.Context context, java.lang.Thread thread, Exception exception, java.util.Map<java.lang.Thread,java.lang.StackTraceElement[]> allStackTraces, long initializeTimestamp, boolean fatal)static ManagedErrorLogcreateErrorLog(android.content.Context context, java.lang.Thread thread, java.lang.Throwable throwable, java.util.Map<java.lang.Thread,java.lang.StackTraceElement[]> allStackTraces, long initializeTimestamp)static ErrorReportgetErrorReportFromErrorLog(ManagedErrorLog log, java.lang.String stackTrace)static java.io.FilegetErrorStorageDirectory()static java.io.FilegetLastErrorLogFile()static ExceptiongetModelExceptionFromThrowable(java.lang.Throwable t)static java.io.FilegetNewMinidumpDirectory()A general folder where unprocessed NDK crashes are saved.static java.io.File[]getNewMinidumpFiles()static java.io.FilegetNewMinidumpSubfolder()A one-time run-specific folder where unprocessed NDK crashes are saved.static java.io.FilegetNewMinidumpSubfolderWithContextData(android.content.Context context)A one-time run-specific folder where unprocessed NDK crashes are saved.static java.io.FilegetPendingMinidumpDirectory()A folder where minidumps of processed NDK crashes are saved.static com.microsoft.appcenter.ingestion.models.DevicegetStoredDeviceInfo(java.io.File logFolder)Get deviceInfo data.static java.io.File[]getStoredErrorLogFiles()static java.io.FilegetStoredThrowableFile(java.util.UUID id)static java.lang.StringgetStoredUserInfo(java.io.File logFolder)Get userId data.static java.util.UUIDparseLogFolderUuid(java.io.File logFolder)Parse log folder name UUID.static voidremoveLostThrowableFiles()Remove throwable files.static voidremoveMinidumpFolder()Remove the minidump folder.static voidremoveStaleMinidumpSubfolders()Remove the minidump sub-folders from previous sessions in the 'minidump/new' folder.static voidremoveStoredErrorLogFile(java.util.UUID id)static voidremoveStoredThrowableFile(java.util.UUID id)static voidsetErrorLogDirectory(java.io.File file)static java.util.Map<java.lang.String,java.lang.String>validateProperties(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String logType)Validates properties.
-
-
-
Field Detail
-
DEVICE_INFO_FILE
public static final java.lang.String DEVICE_INFO_FILE
Device info filename.- See Also:
- Constant Field Values
-
ERROR_LOG_FILE_EXTENSION
public static final java.lang.String ERROR_LOG_FILE_EXTENSION
Error log file extension for the JSON schema.- See Also:
- Constant Field Values
-
THROWABLE_FILE_EXTENSION
public static final java.lang.String THROWABLE_FILE_EXTENSION
Error log file extension for the serialized throwable for client side inspection.- See Also:
- Constant Field Values
-
FRAME_LIMIT
public static final int FRAME_LIMIT
For huge stack traces such as giant StackOverflowError, we keep only beginning and end of frames according to this limit.- See Also:
- Constant Field Values
-
MAX_PROPERTY_ITEM_LENGTH
public static final int MAX_PROPERTY_ITEM_LENGTH
Max length of properties.- See Also:
- Constant Field Values
-
MINIDUMP_FILE_EXTENSION
public static final java.lang.String MINIDUMP_FILE_EXTENSION
Minidump file extension for the NDK crashes.- See Also:
- Constant Field Values
-
-
Method Detail
-
createErrorLog
@NonNull public static ManagedErrorLog createErrorLog(@NonNull android.content.Context context, @NonNull java.lang.Thread thread, @NonNull java.lang.Throwable throwable, @NonNull java.util.Map<java.lang.Thread,java.lang.StackTraceElement[]> allStackTraces, long initializeTimestamp)
-
createErrorLog
@NonNull public static ManagedErrorLog createErrorLog(@NonNull android.content.Context context, @NonNull java.lang.Thread thread, @NonNull Exception exception, @NonNull java.util.Map<java.lang.Thread,java.lang.StackTraceElement[]> allStackTraces, long initializeTimestamp, boolean fatal)
-
getErrorStorageDirectory
@NonNull public static java.io.File getErrorStorageDirectory()
-
getNewMinidumpDirectory
@NonNull public static java.io.File getNewMinidumpDirectory()
A general folder where unprocessed NDK crashes are saved.- Returns:
- a folder name e.g. /lib/files/error/minidump/new
-
getNewMinidumpSubfolder
@NonNull public static java.io.File getNewMinidumpSubfolder()
A one-time run-specific folder where unprocessed NDK crashes are saved.- Returns:
- a folder name e.g. /lib/files/error/minidump/new/aae16c29-42a9-baee-0777e6ba8fe3
-
getNewMinidumpSubfolderWithContextData
@NonNull public static java.io.File getNewMinidumpSubfolderWithContextData(android.content.Context context)
A one-time run-specific folder where unprocessed NDK crashes are saved. Each launch of the application creates its own sub-folder with a random name to store information about the current device (including the application version), which is used in the error report.- Returns:
- a folder name e.g. /lib/files/error/minidump/new/aae16c29-f9e7-42a9-baee-0777e6ba8fe3
-
getPendingMinidumpDirectory
@NonNull public static java.io.File getPendingMinidumpDirectory()
A folder where minidumps of processed NDK crashes are saved.- Returns:
- a folder name e.g. /lib/files/error/minidump/pending
-
getStoredErrorLogFiles
@NonNull public static java.io.File[] getStoredErrorLogFiles()
-
getNewMinidumpFiles
@NonNull public static java.io.File[] getNewMinidumpFiles()
-
getStoredDeviceInfo
@Nullable public static com.microsoft.appcenter.ingestion.models.Device getStoredDeviceInfo(java.io.File logFolder)
Get deviceInfo data.- Parameters:
logFolder- folder where to look for stored device information.- Returns:
- a device information or null.
-
getStoredUserInfo
public static java.lang.String getStoredUserInfo(java.io.File logFolder)
Get userId data.- Parameters:
logFolder- folder where to look for stored userId.- Returns:
- userId or null.
-
removeStaleMinidumpSubfolders
public static void removeStaleMinidumpSubfolders()
Remove the minidump sub-folders from previous sessions in the 'minidump/new' folder. Minidumps from these folders should already be moved to the 'minidump/pending' folder, so that they can be safely deleted.
-
removeMinidumpFolder
public static void removeMinidumpFolder()
Remove the minidump folder.
-
getLastErrorLogFile
@Nullable public static java.io.File getLastErrorLogFile()
-
getStoredThrowableFile
@Nullable public static java.io.File getStoredThrowableFile(@NonNull java.util.UUID id)
-
removeStoredThrowableFile
public static void removeStoredThrowableFile(@NonNull java.util.UUID id)
-
removeStoredErrorLogFile
public static void removeStoredErrorLogFile(@NonNull java.util.UUID id)
-
removeLostThrowableFiles
public static void removeLostThrowableFiles()
Remove throwable files.
-
getErrorReportFromErrorLog
@NonNull public static ErrorReport getErrorReportFromErrorLog(@NonNull ManagedErrorLog log, java.lang.String stackTrace)
-
setErrorLogDirectory
public static void setErrorLogDirectory(java.io.File file)
-
getModelExceptionFromThrowable
@NonNull public static Exception getModelExceptionFromThrowable(@NonNull java.lang.Throwable t)
-
validateProperties
public static java.util.Map<java.lang.String,java.lang.String> validateProperties(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String logType)Validates properties.- Parameters:
properties- Properties collection to validate.logType- Log type.- Returns:
- valid properties collection with maximum size of 5.
-
cleanPendingMinidumps
public static void cleanPendingMinidumps()
Clear (delete all content) pending minidump directory.
-
parseLogFolderUuid
@NonNull public static java.util.UUID parseLogFolderUuid(java.io.File logFolder)
Parse log folder name UUID. Fallback to random UUID.- Parameters:
logFolder- a folder, e.g. lib/files/error/minidump/new/a80da2ae-8c85-43b0-a25b-d52319fb6d56- Returns:
- parsed UUID or random UUID.
-
clearStaticState
public static void clearStaticState()
-
-