List of usage examples for com.intellij.openapi.diagnostic IdeaLoggingEvent getData
@Nullable
public Object getData()
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);/* w ww.j av a 2s. co m*/ 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.google.cloud.tools.intellij.feedback.GoogleFeedbackErrorReporter.java
License:Apache License
private static void configureErrorFromEvent(IdeaLoggingEvent event, ErrorBean error) { Throwable throwable = event.getThrowable(); if (throwable != null) { PluginId pluginId = IdeErrorsDialog.findPluginId(throwable); if (pluginId != null) { IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId); if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) { error.setPluginName(ideaPluginDescriptor.getName()); error.setPluginVersion(ideaPluginDescriptor.getVersion()); }/* ww w . j a v a 2 s . c o m*/ } } Object data = event.getData(); if (data instanceof AbstractMessage) { error.setAttachments(((AbstractMessage) data).getAttachments()); } }
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 w w w . ja v a 2 s. c om 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.MessagePool.java
License:Apache License
@Nullable public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) { Object data = aEvent.getData(); final LogMessage message = data instanceof LogMessage ? (LogMessage) data : new LogMessage(aEvent); if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) { if (myFatalsGrouper.addToGroup(message)) { return message; }/*from ww w. ja va 2 s .c o m*/ } else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) { String msg = DiagnosticBundle.message("error.monitor.too.many.errors"); LogMessage tooMany = new LogMessage( new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException())); myFatalsGrouper.addToGroup(tooMany); return tooMany; } return null; }
From source file:org.jf.smalidea.errorReporting.ErrorReporter.java
License:Apache License
@Override public boolean submit(IdeaLoggingEvent[] events, String additionalInfo, Component parentComponent, final Consumer<SubmittedReportInfo> consumer) { IdeaLoggingEvent event = events[0]; ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId); final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent); bean.setDescription(additionalInfo); bean.setMessage(event.getMessage()); Throwable throwable = event.getThrowable(); if (throwable != null) { final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable); if (pluginId != null) { final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId); if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) { bean.setPluginName(ideaPluginDescriptor.getName()); bean.setPluginVersion(ideaPluginDescriptor.getVersion()); }//from www.j av a 2s. c o m } } Object data = event.getData(); if (data instanceof LogMessageEx) { bean.setAttachments(((LogMessageEx) data).getAttachments()); } Map<String, String> reportValues = ITNProxy.createParameters(bean); 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); consumer.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) { String message = String.format("<html>There was an error while creating a GitHub issue: %s<br>" + "Please consider manually creating an issue on the " + "<a href=\"https://github.com/JesusFreke/smali/issues\">Smali Issue Tracker</a></html>", e.getMessage()); ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false) .notify(project); } }; GithubFeedbackTask task = new GithubFeedbackTask(project, "Submitting error report", true, reportValues, successCallback, errorCallback); if (project == null) { task.run(new EmptyProgressIndicator()); } else { ProgressManager.getInstance().run(task); } return true; }
From source file:ro.redeul.google.go.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);// www .ja v a 2 s. c om bean.setMessage(event.getMessage()); Throwable throwable = event.getThrowable(); if (throwable != null) { final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable); 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()); } LinkedHashMap<String, String> reportValues = IdeaITNProxy.getKeyValuePairs(bean, ApplicationManager.getApplication(), (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance()); final Project project = CommonDataKeys.PROJECT.getData(dataContext); Consumer<String> successCallback = new Consumer<String>() { @Override public void consume(String response) { java.lang.reflect.Type mapType = new TypeToken<Map<String, Object>>() { }.getType(); Gson gson = new Gson(); Map<String, Object> apiResponse = gson.fromJson(response, mapType); final SubmittedReportInfo reportInfo; reportInfo = new SubmittedReportInfo((String) apiResponse.get("html_url"), Integer.valueOf((String) apiResponse.get("number")).toString(), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE); callback.consume(reportInfo); ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, computeSubmittedText(reportInfo), NotificationType.INFORMATION, null).setImportant(false) .notify(project); } }; Consumer<Exception> errorCallback = new Consumer<Exception>() { @Override public void consume(Exception e) { String message = GoBundle.message("go.error.report.message", e.getMessage()); ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false) .notify(project); } }; AnonymousFeedbackTask task = new AnonymousFeedbackTask(project, "Submitting error report", true, reportValues, successCallback, errorCallback); if (project == null) { task.run(new EmptyProgressIndicator()); } else { ProgressManager.getInstance().run(task); } return true; }