Skip to content
Snippets Groups Projects
Commit 14f01f40 authored by Daniel Haag's avatar Daniel Haag
Browse files

OPENOLAT-265: Send email on every RedScreen including user name and business path

parent 61bd60c3
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ package org.olat.core.gui.exception; ...@@ -30,6 +30,7 @@ package org.olat.core.gui.exception;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.BaseSecurityModule; import org.olat.basesecurity.BaseSecurityModule;
import org.olat.core.CoreSpringFactory; import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
...@@ -62,6 +63,8 @@ import org.olat.core.util.UserSession; ...@@ -62,6 +63,8 @@ import org.olat.core.util.UserSession;
import org.olat.core.util.Util; import org.olat.core.util.Util;
import org.olat.core.util.WebappHelper; import org.olat.core.util.WebappHelper;
import org.olat.core.util.i18n.I18nManager; import org.olat.core.util.i18n.I18nManager;
import org.olat.core.util.mail.MailBundle;
import org.olat.core.util.mail.MailManager;
/** /**
* Description: <br> * Description: <br>
...@@ -235,6 +238,35 @@ public class ExceptionWindowController extends DefaultChiefController { ...@@ -235,6 +238,35 @@ public class ExceptionWindowController extends DefaultChiefController {
w.setContentPane(msg); w.setContentPane(msg);
setWindow(w); setWindow(w);
// send email to support address
try {
// if null, user may crashed before getting a valid session, try with
// guest user instead
if (curIdent == null) {
BaseSecurity im = CoreSpringFactory.getImpl(BaseSecurity.class);
curIdent = im.findIdentityByName("guest");
}
MailBundle bundle = new MailBundle();
bundle.setFromId(curIdent);
bundle.setTo(WebappHelper.getMailConfig("mailError"));
bundle.setContent(
"**RedScreen** Nr.: " + Settings.getNodeInfo() + "-E" + refNum,
"**RedScreen** " + o3e.getLogMsg() + "\n" +
formatter.formatDateAndTime(new Date()) + "\n" +
"Username: " + curIdent.getName() + "\n" +
"Stacktrace:\n" +
OLATRuntimeException.throwableToHtml(th).replaceAll("<br />", "\n") + "\n\n" +
"ListenerInfo\n" +
componentListenerInfo + "\n" +
"Last businesspath: " + msg.contextGet("lastbusinesspath") + "\n" +
"Prev businesspath: " + msg.contextGet("prevbusinesspath") + "\n"
);
CoreSpringFactory.getImpl(MailManager.class).sendExternMessage(bundle, null, false);
} catch (Exception e) {
log.error("Failed to send RedScreen-data via mail", e);
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment