private void writeLogRecToDB(final OL_LogRecord ollr) {
try {
if (_logDb == null)
_logDb = Factory.getSession().getDatabase(_myDBPath);
Document olDoc = _logDb.createDocument();
olDoc.replaceItemValue("Form", _logFormName);
Throwable t = ollr._logRec.getThrown();
if (t != null) {
StackTraceElement[] sttr = t.getStackTrace();
int interestingInd = (sttr.length == 0) ? -11 : 0;
NotesException ne = null;
if (t instanceof NotesException)
ne = (NotesException) t;
else if (t instanceof OpenNTFNotesException && t.getCause() instanceof NotesException) {
ne = (NotesException) t.getCause();
interestingInd++;
}
if (ne != null) {
olDoc.replaceItemValue("LogErrorNumber", ne.id);
olDoc.replaceItemValue("LogErrorMessage", ne.text);
} else
olDoc.replaceItemValue("LogErrorMessage", getMessage(ollr._logRec));
if (interestingInd >= 0) {
StackTraceElement ste = sttr[interestingInd];
olDoc.replaceItemValue("LogErrorLine", ste.getLineNumber());
olDoc.replaceItemValue("LogFromMethod", ste.getClassName() + "." + ste.getMethodName());
}
}
olDoc.replaceItemValue("LogStackTrace", getStackTrace(t));
Level l = ollr._logRec.getLevel();
if (l == null)
l = Level.WARNING;
olDoc.replaceItemValue("LogSeverity", l.getName());
olDoc.replaceItemValue("LogEventTime", new Date(ollr._logRec.getMillis()));
olDoc.replaceItemValue("LogEventType", "Log");
olDoc.replaceItemValue("LogMessage", getMessage(ollr._logRec));
olDoc.replaceItemValue("LogFromDatabase", ollr._dbPath);
olDoc.replaceItemValue("LogFromServer", ollr._serverName);
olDoc.replaceItemValue("LogFromAgent", ollr._agentName);
olDoc.replaceItemValue("LogAgentLanguage", "Java");
olDoc.replaceItemValue("LogUserName", ollr._userName);
olDoc.replaceItemValue("LogEffectiveName", ollr._effectiveUserName);
olDoc.replaceItemValue("LogAccessLevel", ollr._accessLevel);
olDoc.replaceItemValue("LogUserRoles", ollr._userRoles);
olDoc.replaceItemValue("LogClientVersion", ollr._clientVersion);
olDoc.replaceItemValue("LogAgentStartTime", _parentStartTime);
if (ollr._exceptionDetails == null)
olDoc.replaceItemValue("LogExceptionDetails", "* Not available *");
else {
int sz = ollr._exceptionDetails.size();
String[] excds = new String[sz];
for (int i = 0; i < sz; i++)
excds[i] = ollr._exceptionDetails.get(i).toString();
olDoc.replaceItemValue("LogExceptionDetails", excds);
}
if (ollr._lastWrappedDocs == null)
olDoc.replaceItemValue("LogLastWrappedDocuments", "* Not available *");
else
olDoc.replaceItemValue("LogLastWrappedDocuments", ollr._lastWrappedDocs);
olDoc.replaceItemValue("$PublicAccess", "1");
olDoc.save(true);
} catch (Exception e) {
printException(e);
}
}