error reporting: attachments pulled up from LogMessageEx to LogMessage to allow IDEs add default attachments (e.g. log files) to all reports

This commit is contained in:
nik
2016-03-03 15:48:33 +03:00
parent 632ad74ef6
commit 2809c63c9c
2 changed files with 20 additions and 20 deletions
@@ -15,13 +15,20 @@
*/
package com.intellij.diagnostic;
import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SmartList;
import org.apache.log4j.spi.LoggingEvent;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
public class LogMessage extends AbstractMessage {
private final Throwable myThrowable;
private final String myHeader;
private List<Attachment> myAttachments = null;
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public LogMessage(LoggingEvent aEvent) {
@@ -83,4 +90,17 @@ public class LogMessage extends AbstractMessage {
public String getThrowableText() {
return StringUtil.getThrowableText(getThrowable());
}
public void addAttachment(Attachment attachment) {
if (myAttachments == null) {
myAttachments = new SmartList<Attachment>();
}
myAttachments.add(attachment);
}
@NotNull
@Override
public List<Attachment> getAllAttachments() {
return myAttachments != null ? myAttachments : Collections.emptyList();
}
}
@@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,7 +28,6 @@ import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* @author ksafonov
@@ -38,7 +36,6 @@ public class LogMessageEx extends LogMessage {
private final IdeaLoggingEvent myEvent;
private final String myTitle;
private final String myNotificationText;
private List<Attachment> myAttachments = null;
/**
* @param title text to show in Event Log tool window entry (it comes before 'more')
@@ -65,23 +62,6 @@ public class LogMessageEx extends LogMessage {
return myTitle;
}
public void addAttachment(String path, String content) {
addAttachment(new Attachment(path, content));
}
public void addAttachment(Attachment attachment) {
if (myAttachments == null) {
myAttachments = new SmartList<Attachment>();
}
myAttachments.add(attachment);
}
@NotNull
@Override
public List<Attachment> getAllAttachments() {
return myAttachments != null ? myAttachments : Collections.<Attachment>emptyList();
}
public IdeaLoggingEvent toEvent() {
return myEvent;
}