use of com.intellij.openapi.diagnostic.IdeaLoggingEvent in project intellij-community by JetBrains.
the class DialogAppender method appendToLoggers.
void appendToLoggers(@NotNull LoggingEvent event, @NotNull ErrorLogger[] errorLoggers) {
if (myDialogRunnable != null) {
return;
}
final IdeaLoggingEvent ideaEvent;
final Object message = event.getMessage();
if (message instanceof IdeaLoggingEvent) {
ideaEvent = (IdeaLoggingEvent) message;
} else {
ThrowableInformation info = event.getThrowableInformation();
if (info == null) {
return;
}
ideaEvent = extractLoggingEvent(message, info.getThrowable());
}
for (int i = errorLoggers.length - 1; i >= 0; i--) {
final ErrorLogger logger = errorLoggers[i];
if (!logger.canHandle(ideaEvent)) {
continue;
}
myDialogRunnable = () -> {
try {
logger.handle(ideaEvent);
} finally {
myDialogRunnable = null;
}
};
final Application app = ApplicationManager.getApplication();
if (app == null) {
new Thread(myDialogRunnable, "dialog appender logger").start();
} else {
app.executeOnPooledThread(myDialogRunnable);
}
break;
}
}
use of com.intellij.openapi.diagnostic.IdeaLoggingEvent in project intellij-community by JetBrains.
the class DialogAppender method extractLoggingEvent.
private static IdeaLoggingEvent extractLoggingEvent(Object message, Throwable throwable) {
//noinspection ThrowableResultOfMethodCallIgnored
Throwable rootCause = ExceptionUtil.getRootCause(throwable);
if (rootCause instanceof LogEventException) {
return ((LogEventException) rootCause).getLogMessage();
}
String strMessage = message == null ? "<null> " : message.toString();
ExceptionWithAttachments withAttachments = ExceptionUtil.findCause(throwable, ExceptionWithAttachments.class);
if (withAttachments != null) {
return LogMessageEx.createEvent(strMessage, ExceptionUtil.getThrowableText(throwable), withAttachments.getAttachments());
}
return new IdeaLoggingEvent(strMessage, throwable);
}
use of com.intellij.openapi.diagnostic.IdeaLoggingEvent in project intellij-elixir by KronicDeth.
the class Submitter method errorBean.
@NotNull
private static ErrorBean errorBean(@NotNull IdeaLoggingEvent[] events, String additionalInfo) {
IdeaLoggingEvent event = events[0];
ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
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());
}
}
}
Object data = event.getData();
if (data instanceof LogMessageEx) {
bean.setAttachments(includedAttachments((LogMessageEx) data));
}
return bean;
}
use of com.intellij.openapi.diagnostic.IdeaLoggingEvent in project psiviewer by cmf.
the class YouTrackBugReporter method submit.
private SubmittedReportInfo submit(IdeaLoggingEvent[] ideaLoggingEvents, String description, String user, Component component) {
this.description = ideaLoggingEvents[0].getThrowableText().substring(0, Math.min(Math.max(80, ideaLoggingEvents[0].getThrowableText().length()), 80));
this.email = user;
@NonNls StringBuilder descBuilder = new StringBuilder();
String platformBuild = ApplicationInfo.getInstance().getBuild().asString();
descBuilder.append("Platform Version: ").append(platformBuild).append('\n');
Throwable t = ideaLoggingEvents[0].getThrowable();
if (t != null) {
final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
if (pluginId != null) {
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
descBuilder.append("Plugin ").append(ideaPluginDescriptor.getName()).append(" version: ").append(ideaPluginDescriptor.getVersion()).append("\n");
this.affectedVersion = ideaPluginDescriptor.getVersion();
}
}
}
if (user == null)
user = "<none>";
if (description == null)
description = "<none>";
descBuilder.append("\n\nDescription: ").append(description).append("\n\nUser: ").append(user);
for (IdeaLoggingEvent e : ideaLoggingEvents) descBuilder.append("\n\n").append(e.toString());
this.extraInformation = descBuilder.toString();
String result = submit();
log.info("Error submitted, response: " + result);
if (result == null)
return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
String ResultString = null;
try {
Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
Matcher regexMatcher = regex.matcher(result);
if (regexMatcher.find()) {
ResultString = regexMatcher.group(1);
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
SubmittedReportInfo.SubmissionStatus status = NEW_ISSUE;
if (ResultString == null)
return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
return new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString, ResultString, status);
}
Aggregations