Search in sources :

Example 6 with IdeaLoggingEvent

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;
    }
}
Also used : ThrowableInformation(org.apache.log4j.spi.ThrowableInformation) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Application(com.intellij.openapi.application.Application) IdeaApplication(com.intellij.idea.IdeaApplication) ErrorLogger(com.intellij.openapi.diagnostic.ErrorLogger)

Example 7 with IdeaLoggingEvent

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);
}
Also used : ExceptionWithAttachments(com.intellij.openapi.diagnostic.ExceptionWithAttachments) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent)

Example 8 with IdeaLoggingEvent

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;
}
Also used : ErrorBean(com.intellij.errorreport.bean.ErrorBean) LogMessageEx(com.intellij.diagnostic.LogMessageEx) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with IdeaLoggingEvent

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);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Aggregations

IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)9 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)6 PluginId (com.intellij.openapi.extensions.PluginId)6 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)5 DataContext (com.intellij.openapi.actionSystem.DataContext)4 Project (com.intellij.openapi.project.Project)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2 Consumer (com.intellij.util.Consumer)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (com.android.annotations.Nullable)1 CrashReport (com.android.tools.idea.diagnostics.crash.CrashReport)1 CrashReporter (com.android.tools.idea.diagnostics.crash.CrashReporter)1 Maps (com.google.common.collect.Maps)1 AbstractMessage (com.intellij.diagnostic.AbstractMessage)1 IdeErrorsDialog (com.intellij.diagnostic.IdeErrorsDialog)1 ReportMessages (com.intellij.diagnostic.ReportMessages)1 DataManager (com.intellij.ide.DataManager)1