Example usage for com.intellij.openapi.diagnostic IdeaLoggingEvent getMessage

List of usage examples for com.intellij.openapi.diagnostic IdeaLoggingEvent getMessage

Introduction

In this page you can find the example usage for com.intellij.openapi.diagnostic IdeaLoggingEvent getMessage.

Prototype

public String getMessage() 

Source Link

Usage

From source file:bazaar4idea.util.BzrErrorReportSubmitter.java

License:Apache License

/**
 * @noinspection ThrowablePrintStackTrace,ThrowableResultOfMethodCallIgnored
 *///from  www. j a v  a  2  s  .com
private static SubmittedReportInfo sendError(IdeaLoggingEvent event, Component parentComponent) {
    NotifierBean notifierBean = new NotifierBean();
    ErrorBean errorBean = new ErrorBean();
    errorBean.autoInit();
    //    errorBean.setLastAction(IdeaLogger.ourLastActionId);

    int threadId = 0;
    SubmittedReportInfo.SubmissionStatus submissionStatus = SubmittedReportInfo.SubmissionStatus.FAILED;

    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    Project project = PlatformDataKeys.PROJECT.getData(dataContext);

    String description = "";
    do {
        // prepare
        try {
            ErrorReportSender sender = ErrorReportSender.getInstance();
            //
            sender.prepareError(project, event.getThrowable());
            //
            BzrSendErrorForm dlg = new BzrSendErrorForm();
            dlg.setErrorDescription(description);
            dlg.show();

            BzrErrorReportConfigurable reportConf = BzrErrorReportConfigurable.getInstance();
            @NonNls
            String senderEmail = reportConf.EMAIL_ADDRESS;
            @NonNls
            String smtpServer = reportConf.SMTP_SERVER;
            @NonNls
            String itnLogin = reportConf.AUTH_USERNAME;
            @NonNls
            String itnPassword = reportConf.getPlainItnPassword();
            notifierBean.setEmailAddress(senderEmail);
            notifierBean.setSmtpServer(smtpServer);
            notifierBean.setItnLogin(itnLogin);
            notifierBean.setItnPassword(itnPassword);
            //
            description = dlg.getErrorDescription();
            String message = event.getMessage();
            //
            @NonNls
            StringBuilder descBuilder = new StringBuilder();
            if (description.length() > 0) {
                descBuilder.append("User description: ").append(description).append("\n");
            }
            if (message != null) {
                descBuilder.append("Error message: ").append(message).append("\n");
            }

            Throwable t = event.getThrowable();
            if (t != null) {
                //          final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
                //          if (pluginId != null) {
                //            final IdeaPluginDescriptor ideaPluginDescriptor = ApplicationManager.getApplication().getPlugin(pluginId);
                //            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                //              descBuilder.append("Plugin version: ").append(ideaPluginDescriptor.getVersion()).append("\n");
                //            }
                //          }
            }

            if (previousExceptionThreadId != 0) {
                descBuilder.append("Previous exception is: ").append(URL_HEADER)
                        .append(previousExceptionThreadId).append("\n");
            }
            if (wasException) {
                descBuilder.append("There was at least one exception before this one.\n");
            }

            errorBean.setDescription(descBuilder.toString());

            if (dlg.isShouldSend()) {
                threadId = sender.sendError(notifierBean, errorBean);
                previousExceptionThreadId = threadId;
                wasException = true;
                submissionStatus = SubmittedReportInfo.SubmissionStatus.NEW_ISSUE;

                Messages.showInfoMessage(parentComponent, BzrBundle.message("error.report.confirmation"),
                        ERROR_REPORT);
                break;
            } else {
                break;
            }

            //      } catch (NoSuchEAPUserException e) {
            //        if (Messages.showYesNoDialog(parentComponent, DiagnosticBundle.message("error.report.authentication.failed"),
            //                                     ReportMessages.ERROR_REPORT, Messages.getErrorIcon()) != 0) {
            //          break;
            //        }
            //      } catch (InternalEAPException e) {
            //        if (Messages.showYesNoDialog(parentComponent, DiagnosticBundle.message("error.report.posting.failed", e.getMessage()),
            //                                     ReportMessages.ERROR_REPORT, Messages.getErrorIcon()) != 0) {
            //          break;
            //        }
            //      } catch (IOException e) {
            //        if (!IOExceptionDialog.showErrorDialog(BzrVcsMessages.message("error.report.exception.title"),
            //                                               BzrVcsMessages.message("error.report.failure.message"))) {
            //          break;
            //        }
            //      } catch (NewBuildException e) {
            //        Messages.showMessageDialog(parentComponent,
            //                                   DiagnosticBundle.message("error.report.new.eap.build.message", e.getMessage()), CommonBundle.getWarningTitle(),
            //                                   Messages.getWarningIcon());
            //        break;
        } catch (Exception e) {
            LOG.info(e);
            if (Messages.showYesNoDialog(JOptionPane.getRootFrame(),
                    BzrBundle.message("error.report.sending.failure"), ERROR_REPORT,
                    Messages.getErrorIcon()) != 0) {
                break;
            }
        }

    } while (true);

    return new SubmittedReportInfo(
            submissionStatus != SubmittedReportInfo.SubmissionStatus.FAILED ? URL_HEADER + threadId : null,
            String.valueOf(threadId), submissionStatus);
}

From source file:com.android.tools.idea.diagnostics.error.ErrorReporter.java

License:Apache License

private static boolean doSubmit(final IdeaLoggingEvent event, final Component parentComponent,
        final Consumer<SubmittedReportInfo> callback, final ErrorBean bean, final String description) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);

    bean.setDescription(description);/*from   w  w w  . ja  v  a2  s. com*/
    bean.setMessage(event.getMessage());

    Throwable t = event.getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                bean.setPluginName(ideaPluginDescriptor.getName());
                bean.setPluginVersion(ideaPluginDescriptor.getVersion());
            }
        }
    }

    Object data = event.getData();

    if (data instanceof LogMessageEx) {
        bean.setAttachments(((LogMessageEx) data).getAttachments());
    }

    List<Pair<String, String>> kv = IdeaITNProxy.getKeyValuePairs(null, null, bean,
            IdeaLogger.getOurCompilationTimestamp(), ApplicationManager.getApplication(),
            (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance(),
            UpdateSettings.getInstance());

    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);

    Consumer<String> successCallback = new Consumer<String>() {
        @Override
        public void consume(String token) {
            final SubmittedReportInfo reportInfo = new SubmittedReportInfo(null, "Issue " + token,
                    SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
            callback.consume(reportInfo);

            ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, "Submitted",
                    NotificationType.INFORMATION, null).setImportant(false).notify(project);
        }
    };

    Consumer<Exception> errorCallback = new Consumer<Exception>() {
        @Override
        public void consume(Exception e) {
            // TODO: check for updates
            String message = AndroidBundle.message("error.report.at.b.android", e.getMessage());
            NotificationListener listener = new NotificationListener.UrlOpeningListener(true);
            ReportMessages.GROUP
                    .createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, listener)
                    .setImportant(false).notify(project);
        }
    };
    AnonymousFeedbackTask task = new AnonymousFeedbackTask(project, "Submitting error report", true, t,
            pair2map(kv), bean.getMessage(), bean.getDescription(),
            ApplicationInfo.getInstance().getFullVersion(), successCallback, errorCallback);
    if (project == null) {
        task.run(new EmptyProgressIndicator());
    } else {
        ProgressManager.getInstance().run(task);
    }
    return true;
}

From source file:com.atlassian.theplugin.idea.BlameAtlassian.java

License:Apache License

public SubmittedReportInfo submit(IdeaLoggingEvent[] ideaLoggingEvents, Component component) {
    StringBuilder description = new StringBuilder();
    for (IdeaLoggingEvent ideaLoggingEvent : ideaLoggingEvents) {
        description.append(ideaLoggingEvent.getMessage());
        description.append("\n");
        description.append(ideaLoggingEvent.getThrowableText());
        description.append("\n");
    }/*www. j  a v a  2s  . c  om*/

    // there is no getBuild().asString() in IDEA 8.0 and older, so we need to use
    // deprecated getBuildNumber() method here...
    @SuppressWarnings("deprecation")
    String buildNumber = ApplicationInfo.getInstance().getBuildNumber();
    BrowserUtil.launchBrowser(BugReporting.getBugWithDescriptionUrl(buildNumber, description.toString()));

    return new SubmittedReportInfo(null, "JIRA ticket", SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
}

From source file:com.google.cloud.tools.intellij.feedback.GoogleFeedbackErrorReporter.java

License:Apache License

private static boolean doSubmit(final IdeaLoggingEvent event, final Component parentComponent,
        final Consumer<SubmittedReportInfo> callback, final ErrorBean error, final String description) {
    error.setDescription(description);/*from   ww  w. j a  v a2s  .  co m*/
    error.setMessage(event.getMessage());

    configureErrorFromEvent(event, error);

    ApplicationNamesInfo intelliJAppNameInfo = ApplicationNamesInfo.getInstance();
    ApplicationInfoEx intelliJAppExtendedInfo = ApplicationInfoEx.getInstanceEx();

    Map<String, String> params = buildKeyValuesMap(error, intelliJAppNameInfo, intelliJAppExtendedInfo,
            ApplicationManager.getApplication());

    DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);

    Consumer<String> successCallback = new Consumer<String>() {
        @Override
        public void consume(String token) {
            final SubmittedReportInfo reportInfo = new SubmittedReportInfo(null, "Issue " + token,
                    SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
            callback.consume(reportInfo);

            ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, "Submitted",
                    NotificationType.INFORMATION, null).setImportant(false).notify(project);
        }
    };

    Consumer<Exception> errorCallback = new Consumer<Exception>() {
        @Override
        public void consume(Exception ex) {
            String message = ErrorReporterBundle.message("error.googlefeedback.error", ex.getMessage());
            ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message,
                    NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false)
                    .notify(project);
        }
    };
    GoogleAnonymousFeedbackTask task = new GoogleAnonymousFeedbackTask(project, "Submitting error report", true,
            event.getThrowable(), params, error.getMessage(), error.getDescription(),
            ApplicationInfo.getInstance().getFullVersion(), successCallback, errorCallback);
    if (project == null) {
        task.run(new EmptyProgressIndicator());
    } else {
        ProgressManager.getInstance().run(task);
    }
    return true;
}

From source file:com.intellij.diagnostic.ITNReporter2.java

License:Apache License

private static boolean doSubmit(final IdeaLoggingEvent event, final Component parentComponent,
        final Consumer<SubmittedReportInfo> callback, final ErrorBean errorBean, final String description) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);

    final ErrorReportConfigurable errorReportConfigurable = ErrorReportConfigurable.getInstance();
    if (!errorReportConfigurable.KEEP_ITN_PASSWORD && !StringUtil.isEmpty(errorReportConfigurable.ITN_LOGIN)
            && StringUtil.isEmpty(errorReportConfigurable.getPlainItnPassword())) {
        final JetBrainsAccountDialog dlg = new JetBrainsAccountDialog(parentComponent);
        dlg.show();/*from   www .j av a 2s .  c  o m*/
        if (!dlg.isOK()) {
            return false;
        }
    }

    errorBean.setDescription(description);
    errorBean.setMessage(event.getMessage());

    if (previousExceptionThreadId != 0) {
        errorBean.setPreviousException(previousExceptionThreadId);
    }

    Throwable t = event.getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                errorBean.setPluginName(ideaPluginDescriptor.getName());
                errorBean.setPluginVersion(ideaPluginDescriptor.getVersion());
            }
        }
    }

    Object data = event.getData();

    if (data instanceof AbstractMessage) {
        errorBean.setAssigneeId(((AbstractMessage) data).getAssigneeId());
    }

    if (data instanceof LogMessageEx) {
        errorBean.setAttachments(((LogMessageEx) data).getAttachments());
    }

    @NonNls
    String login = errorReportConfigurable.ITN_LOGIN;
    @NonNls
    String password = errorReportConfigurable.getPlainItnPassword();
    if (login.trim().length() == 0 && password.trim().length() == 0) {
        login = "idea_anonymous";
        password = "guest";
    }

    ErrorReportSender.sendError(project, login, password, errorBean, new Consumer<Integer>() {
        @SuppressWarnings({ "AssignmentToStaticFieldFromInstanceMethod" })
        @Override
        public void consume(Integer threadId) {
            previousExceptionThreadId = threadId;
            wasException = true;
            final SubmittedReportInfo reportInfo = new SubmittedReportInfo(URL_HEADER + threadId,
                    String.valueOf(threadId), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
            callback.consume(reportInfo);
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    StringBuilder text = new StringBuilder();
                    final String url = IdeErrorsDialog.getUrl(reportInfo, true);
                    IdeErrorsDialog.appendSubmissionInformation(reportInfo, text, url);
                    text.append(".");
                    if (reportInfo.getStatus() != SubmittedReportInfo.SubmissionStatus.FAILED) {
                        text.append("<br/>").append(DiagnosticBundle.message("error.report.gratitude"));
                    }

                    NotificationType type = reportInfo
                            .getStatus() == SubmittedReportInfo.SubmissionStatus.FAILED ? NotificationType.ERROR
                                    : NotificationType.INFORMATION;
                    NotificationListener listener = url != null
                            ? new NotificationListener.UrlOpeningListener(true)
                            : null;
                    ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT,
                            XmlStringUtil.wrapInHtml(text), type, listener).setImportant(false).notify(project);
                }
            });
        }
    }, new Consumer<Exception>() {
        @Override
        public void consume(final Exception e) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    String msg;
                    if (e instanceof NoSuchEAPUserException) {
                        msg = DiagnosticBundle.message("error.report.authentication.failed");
                    } else if (e instanceof InternalEAPException) {
                        msg = DiagnosticBundle.message("error.report.posting.failed", e.getMessage());
                    } else {
                        msg = DiagnosticBundle.message("error.report.sending.failure");
                    }
                    if (e instanceof UpdateAvailableException) {
                        String message = DiagnosticBundle.message("error.report.new.eap.build.message",
                                e.getMessage());
                        showMessageDialog(parentComponent, project, message, CommonBundle.getWarningTitle(),
                                Messages.getWarningIcon());
                        callback.consume(new SubmittedReportInfo(null, "0",
                                SubmittedReportInfo.SubmissionStatus.FAILED));
                    } else if (showYesNoDialog(parentComponent, project, msg, ReportMessages.ERROR_REPORT,
                            Messages.getErrorIcon()) != 0) {
                        callback.consume(new SubmittedReportInfo(null, "0",
                                SubmittedReportInfo.SubmissionStatus.FAILED));
                    } else {
                        if (e instanceof NoSuchEAPUserException) {
                            final JetBrainsAccountDialog dialog;
                            if (parentComponent.isShowing()) {
                                dialog = new JetBrainsAccountDialog(parentComponent);
                            } else {
                                dialog = new JetBrainsAccountDialog(project);
                            }
                            dialog.show();
                        }
                        ApplicationManager.getApplication().invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                doSubmit(event, parentComponent, callback, errorBean, description);
                            }
                        });
                    }
                }
            });
        }
    });
    return true;
}

From source file:com.intellij.diagnostic.LogEventException.java

License:Apache License

public LogEventException(IdeaLoggingEvent logMessage) {
    super(logMessage.getMessage());
    myLogMessage = logMessage;
}

From source file:com.intellij.diagnostic.LogMessage.java

License:Apache License

public LogMessage(IdeaLoggingEvent aEvent) {
    super();/*from w  w w .  ja  v a  2  s . c  om*/

    myThrowable = aEvent.getThrowable();

    if (StringUtil.isNotEmpty(aEvent.getMessage())) {
        myHeader = aEvent.getMessage();
    }

    if (myThrowable != null && StringUtil.isNotEmpty(myThrowable.getMessage())) {
        if (!myHeader.equals(NO_MESSAGE)) {
            if (!myHeader.endsWith(": ") && !myHeader.endsWith(":")) {
                myHeader += ": ";
            }
            myHeader += myThrowable.getMessage();
        } else {
            myHeader = myThrowable.getMessage();
        }
    }
}

From source file:com.urswolfer.intellij.plugin.gerrit.errorreport.PluginErrorReportSubmitter.java

License:Apache License

private ErrorBean createErrorBean(IdeaLoggingEvent loggingEvent, String additionalInfo) {
    ErrorBean errorBean = new ErrorBean();
    errorBean.setAdditionInfo(additionalInfo);
    errorBean.setPluginVersion(Version.get());
    ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    String intellijVersion = String.format("%s %s.%s", appInfo.getVersionName(), appInfo.getMajorVersion(),
            appInfo.getMinorVersion());//from  w  ww  .  j  av a 2 s .  c  om
    errorBean.setIntellijVersion(intellijVersion);
    errorBean.setException(loggingEvent.getThrowableText());
    errorBean.setExceptionMessage(loggingEvent.getMessage());
    return errorBean;
}

From source file:io.flutter.FlutterErrorReportSubmitter.java

License:Open Source License

@SuppressWarnings("deprecation")
@Override/* w  w w  .  j ava  2  s.com*/
public void submitAsync(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo,
        @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) {
    if (events.length == 0) {
        consumer.consume(new SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.FAILED));
        return;
    }

    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        project = ProjectManager.getInstance().getDefaultProject();
    }

    final StringBuilder builder = new StringBuilder();

    builder.append("Please file this bug report at https://github.com/flutter/flutter-intellij/issues/new.\n");
    builder.append("\n");
    builder.append("---\n");
    builder.append("\n");

    builder.append("## What happened\n");
    builder.append("\n");
    if (additionalInfo != null) {
        builder.append(additionalInfo.trim()).append("\n");
    } else {
        builder.append("(please describe what you were doing when this exception occurred)\n");
    }
    builder.append("\n");

    builder.append("## Version information\n");
    builder.append("\n");

    // IntelliJ version
    final ApplicationInfo info = ApplicationInfo.getInstance();
    builder.append(info.getVersionName()).append(" `").append(info.getFullVersion()).append("`");

    final IdeaPluginDescriptor flutterPlugin = PluginManager.getPlugin(PluginId.getId("io.flutter"));
    //noinspection ConstantConditions
    builder.append("  Flutter plugin `").append(flutterPlugin.getVersion()).append("`");

    final IdeaPluginDescriptor dartPlugin = PluginManager.getPlugin(PluginId.getId("Dart"));
    if (dartPlugin != null) {
        //noinspection ConstantConditions
        builder.append("  Dart plugin `").append(dartPlugin.getVersion()).append("`");
    }
    builder.append("\n\n");

    final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
    if (sdk == null) {
        builder.append("No Flutter sdk configured.\n");
    } else {
        final String flutterVersion = getFlutterVersion(sdk);
        if (flutterVersion != null) {
            builder.append(flutterVersion.trim()).append("\n");
        } else {
            builder.append("Error getting Flutter sdk information.\n");
        }
    }
    builder.append("\n");

    for (IdeaLoggingEvent event : events) {
        builder.append("## Exception\n");
        builder.append("\n");
        builder.append(event.getMessage()).append("\n");
        builder.append("\n");

        if (event.getThrowable() != null) {
            builder.append("```\n");
            builder.append(event.getThrowableText().trim()).append("\n");
            builder.append("```\n");
            builder.append("\n");

            FlutterInitializer.getAnalytics().sendException(event.getThrowable(), false);
        }
    }

    final String text = builder.toString().trim() + "\n";

    // Create scratch file.
    final ScratchRootType scratchRoot = ScratchRootType.getInstance();
    final VirtualFile file = scratchRoot.createScratchFile(project, "bug-report.md", Language.ANY, text);

    if (file != null) {
        // Open the file.
        new OpenFileDescriptor(project, file).navigate(true);
    } else {
        consumer.consume(new SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.FAILED));
    }

    consumer.consume(new SubmittedReportInfo(null, "", SubmittedReportInfo.SubmissionStatus.NEW_ISSUE));
}

From source file:nu.studer.idea.errorreporting.LoggingEventSubmitter.java

License:Apache License

void submit(@NotNull IdeaLoggingEvent[] events, @Nullable String description, @Nullable String user)
        throws SubmitException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("About to send logging events " + Arrays.asList(events));
    }//w w w .  j a  v  a 2 s  . c  o  m

    // open connection
    URLConnection connection;
    try {
        URL url = new URL(serverURL);
        connection = url.openConnection();
        connection.setRequestProperty("Content-type", "application/octet-stream");
        connection.setConnectTimeout(15 * 1000);
        connection.setReadTimeout(15 * 1000);
        connection.setUseCaches(false);
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.connect();
        connection.getOutputStream();
    } catch (IOException ioe) {
        LOGGER.info("Unable to connect to server", ioe);
        throw new SubmitException("Unable to connect to server", ioe);
    }

    // write events to server
    DataOutputStream stream = null;
    try {
        stream = new DataOutputStream(new DeflaterOutputStream(connection.getOutputStream()));
        stream.writeUTF(pluginId != null ? pluginId : "");
        stream.writeUTF(pluginName != null ? pluginName : "");
        stream.writeUTF(pluginVersion != null ? pluginVersion : "");
        stream.writeUTF(ideaBuild != null ? ideaBuild : "");
        stream.writeUTF(emailTo != null ? StringUtil.join(emailTo, ":") : "");
        stream.writeUTF(emailCc != null ? StringUtil.join(emailCc, ":") : "");
        stream.writeUTF(user != null ? user : "");
        stream.writeUTF(description != null ? description : "");
        stream.writeInt(events.length);
        for (IdeaLoggingEvent event : events) {
            stream.writeUTF(event.getMessage() != null ? event.getMessage() : "");
            stream.writeUTF(event.getThrowableText() != null ? event.getThrowableText() : "");
        }
        stream.flush();
    } catch (IOException ioe) {
        LOGGER.info("Unable to send data to server", ioe);
        throw new SubmitException("Unable to send data to server", ioe);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException ioe) {
                LOGGER.info("Unable to disconnect from server after sending data", ioe);
            }
        }
    }

    LOGGER.debug("Logging events sent successfully");

    // read response from server
    DataInputStream inputStream;
    try {
        inputStream = new DataInputStream(new InflaterInputStream(connection.getInputStream()));
        boolean statusOK = inputStream.readBoolean();
        String statusMessage = inputStream.readUTF();

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Status OK: " + statusOK);
            LOGGER.debug("Status message: " + statusMessage);
        }

        if (!statusOK) {
            LOGGER.info("Status returned by server is NOK");
            throw new SubmitException(statusMessage, null);
        } else {
            LOGGER.info("Status returned by server is OK");
        }
    } catch (IOException ioe) {
        LOGGER.info("Unable to receive data from server", ioe);
        throw new SubmitException("Unable to receive data from server", ioe);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException ioe) {
                LOGGER.info("Unable to disconnect from server after receiving data", ioe);
            }
        }
    }

    // disconnect connection
    if (connection instanceof HttpURLConnection) {
        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        try {
            int responseCode = httpConnection.getResponseCode();
            String responseMessage = httpConnection.getResponseMessage();

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Response code: " + responseCode);
                LOGGER.debug("Response message: " + responseMessage);
            }
        } catch (IOException ioe) {
            LOGGER.info("Unable to retrieve response status");
        } finally {
            httpConnection.disconnect();
        }
    }
}