Search in sources :

Example 6 with Logger

use of com.google.firebase.crashlytics.internal.Logger in project GreenHouse by utsanjan.

the class CrashlyticsReportPersistence method synthesizeReportFile.

private static void synthesizeReportFile(File reportFile, File outputDirectory, List<CrashlyticsReport.Session.Event> events, long sessionEndTime, boolean isCrashed, String userId) {
    try {
        CrashlyticsReport report = TRANSFORM.reportFromJson(readTextFile(reportFile)).withSessionEndFields(sessionEndTime, isCrashed, userId).withEvents(ImmutableList.from(events));
        CrashlyticsReport.Session session = report.getSession();
        if (session != null) {
            writeTextFile(new File(prepareDirectory(outputDirectory), session.getIdentifier()), TRANSFORM.reportToJson(report));
        }
    } catch (IOException e) {
        Logger logger = Logger.getLogger();
        logger.d("Could not synthesize final report file for " + reportFile, e);
    }
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) IOException(java.io.IOException) Logger(com.google.firebase.crashlytics.internal.Logger) File(java.io.File)

Example 7 with Logger

use of com.google.firebase.crashlytics.internal.Logger in project GreenHouse by utsanjan.

the class CrashlyticsReportPersistence method persistReport.

public void persistReport(CrashlyticsReport report) {
    CrashlyticsReport.Session session = report.getSession();
    if (session == null) {
        Logger.getLogger().d("Could not get session for report");
        return;
    }
    String sessionId = session.getIdentifier();
    try {
        File sessionDirectory = prepareDirectory(getSessionDirectoryById(sessionId));
        String json = TRANSFORM.reportToJson(report);
        writeTextFile(new File(sessionDirectory, REPORT_FILE_NAME), json);
    } catch (IOException e) {
        Logger logger = Logger.getLogger();
        logger.d("Could not persist report for session " + sessionId, e);
    }
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) IOException(java.io.IOException) Logger(com.google.firebase.crashlytics.internal.Logger) File(java.io.File)

Example 8 with Logger

use of com.google.firebase.crashlytics.internal.Logger in project GreenHouse by utsanjan.

the class CrashlyticsReportPersistence method synthesizeNativeReportFile.

private static void synthesizeNativeReportFile(File reportFile, File outputDirectory, CrashlyticsReport.FilesPayload ndkPayload, String previousSessionId) {
    try {
        CrashlyticsReport report = TRANSFORM.reportFromJson(readTextFile(reportFile)).withNdkPayload(ndkPayload);
        writeTextFile(new File(prepareDirectory(outputDirectory), previousSessionId), TRANSFORM.reportToJson(report));
    } catch (IOException e) {
        Logger logger = Logger.getLogger();
        logger.d("Could not synthesize final native report file for " + reportFile, e);
    }
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) IOException(java.io.IOException) Logger(com.google.firebase.crashlytics.internal.Logger) File(java.io.File)

Example 9 with Logger

use of com.google.firebase.crashlytics.internal.Logger in project GreenHouse by utsanjan.

the class CrashlyticsController method closeOpenSessions.

private void closeOpenSessions(File[] sessionBeginFiles, int beginIndex, int maxLoggedExceptionsCount) {
    Logger.getLogger().d("Closing open sessions.");
    for (int i = beginIndex; i < sessionBeginFiles.length; i++) {
        File sessionBeginFile = sessionBeginFiles[i];
        String sessionIdentifier = getSessionIdFromSessionFile(sessionBeginFile);
        Logger logger = Logger.getLogger();
        logger.d("Closing session: " + sessionIdentifier);
        writeSessionPartsToSessionFile(sessionBeginFile, sessionIdentifier, maxLoggedExceptionsCount);
    }
}
Also used : Logger(com.google.firebase.crashlytics.internal.Logger) File(java.io.File)

Example 10 with Logger

use of com.google.firebase.crashlytics.internal.Logger in project GreenHouse by utsanjan.

the class CrashlyticsController method handleUncaughtException.

synchronized void handleUncaughtException(final SettingsDataProvider settingsDataProvider, final Thread thread, final Throwable ex) {
    Logger logger = Logger.getLogger();
    logger.d("Crashlytics is handling uncaught exception \"" + ex + "\" from thread " + thread.getName());
    final Date time = new Date();
    final Task<Void> recordFatalFirebaseEventTask = recordFatalFirebaseEvent(time.getTime());
    Task<Void> handleUncaughtExceptionTask = this.backgroundWorker.submitTask(new // from class: com.google.firebase.crashlytics.internal.common.CrashlyticsController.6
    Callable<Task<Void>>() {

        /* JADX WARN: Can't rename method to resolve collision */
        // java.util.concurrent.Callable
        @Override
        public Task<Void> call() throws Exception {
            CrashlyticsController.this.crashMarker.create();
            long timestampSeconds = CrashlyticsController.getTimestampSeconds(time);
            CrashlyticsController.this.reportingCoordinator.persistFatalEvent(ex, thread, timestampSeconds);
            CrashlyticsController.this.writeFatal(thread, ex, timestampSeconds);
            Settings settings = settingsDataProvider.getSettings();
            int maxCustomExceptionEvents = settings.getSessionData().maxCustomExceptionEvents;
            int maxCompleteSessionsCount = settings.getSessionData().maxCompleteSessionsCount;
            CrashlyticsController.this.doCloseSessions(maxCustomExceptionEvents);
            CrashlyticsController.this.doOpenSession();
            CrashlyticsController.this.trimSessionFiles(maxCompleteSessionsCount);
            if (!CrashlyticsController.this.dataCollectionArbiter.isAutomaticDataCollectionEnabled()) {
                return Tasks.forResult(null);
            }
            final Executor executor = CrashlyticsController.this.backgroundWorker.getExecutor();
            return settingsDataProvider.getAppSettings().onSuccessTask(executor, new // from class: com.google.firebase.crashlytics.internal.common.CrashlyticsController.6.1
            SuccessContinuation<AppSettingsData, Void>() {

                public Task<Void> then(AppSettingsData appSettingsData) throws Exception {
                    if (appSettingsData == null) {
                        Logger.getLogger().w("Received null app settings, cannot send reports at crash time.");
                        return Tasks.forResult(null);
                    }
                    CrashlyticsController.this.sendSessionReports(appSettingsData, true);
                    return Tasks.whenAll(CrashlyticsController.this.reportingCoordinator.sendReports(executor, DataTransportState.getState(appSettingsData)), recordFatalFirebaseEventTask);
                }
            });
        }
    });
    try {
        Utils.awaitEvenIfOnMainThread(handleUncaughtExceptionTask);
    } catch (Exception e) {
    }
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) Task(com.google.android.gms.tasks.Task) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Executor(java.util.concurrent.Executor) Logger(com.google.firebase.crashlytics.internal.Logger) SuccessContinuation(com.google.android.gms.tasks.SuccessContinuation) Date(java.util.Date) IOException(java.io.IOException) Settings(com.google.firebase.crashlytics.internal.settings.model.Settings)

Aggregations

Logger (com.google.firebase.crashlytics.internal.Logger)33 IOException (java.io.IOException)12 File (java.io.File)10 CrashlyticsReport (com.google.firebase.crashlytics.internal.model.CrashlyticsReport)4 HttpRequest (com.google.firebase.crashlytics.internal.network.HttpRequest)4 HttpResponse (com.google.firebase.crashlytics.internal.network.HttpResponse)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 JSONObject (org.json.JSONObject)2 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 SuccessContinuation (com.google.android.gms.tasks.SuccessContinuation)1 Task (com.google.android.gms.tasks.Task)1 NativeSessionFileProvider (com.google.firebase.crashlytics.internal.NativeSessionFileProvider)1 AnalyticsConnectorReceiver (com.google.firebase.crashlytics.internal.analytics.AnalyticsConnectorReceiver)1 AnalyticsReceiver (com.google.firebase.crashlytics.internal.analytics.AnalyticsReceiver)1 CrashlyticsReportWithSessionId (com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)1 LogFileManager (com.google.firebase.crashlytics.internal.log.LogFileManager)1 HttpRequestFactory (com.google.firebase.crashlytics.internal.network.HttpRequestFactory)1 FileStore (com.google.firebase.crashlytics.internal.persistence.FileStore)1 FileStoreImpl (com.google.firebase.crashlytics.internal.persistence.FileStoreImpl)1