Search in sources :

Example 1 with ErrorLogger

use of com.intellij.openapi.diagnostic.ErrorLogger 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)

Aggregations

IdeaApplication (com.intellij.idea.IdeaApplication)1 Application (com.intellij.openapi.application.Application)1 ErrorLogger (com.intellij.openapi.diagnostic.ErrorLogger)1 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)1 ThrowableInformation (org.apache.log4j.spi.ThrowableInformation)1