public static ExceptionLog log(ExceptionLog exception) {
return logger.log(exception);
}
public static ExceptionLog log(Exception e, String contextMessage, String user, String telecentro) {
ExceptionLog eLog = new ExceptionLog();
eLog.setContextMessage(contextMessage);
eLog.setException(e.getClass().getName());
eLog.setMessage(e.getMessage());
eLog.setUser(UserContext.getInstance().getUsuario());
StringBuffer buffer = new StringBuffer();
int length = e.getStackTrace().length;
for (int i = 0; i < length; i++) {
buffer.append(e.getStackTrace()[i].getClassName() + STACK_DELIMITER);
buffer.append(e.getStackTrace()[i].getMethodName() + STACK_DELIMITER);
String tmpFileName = e.getStackTrace()[i].getFileName();
buffer.append( (tmpFileName == null ? "" : tmpFileName) + STACK_DELIMITER);
int tmpLineNumber = e.getStackTrace()[i].getLineNumber();
buffer.append(tmpLineNumber < 1 ? "" : tmpLineNumber);
buffer.append(i < length ? "\n" : "");
}
eLog.setStackTrace(buffer.toString());
eLog.setUserName(user);
eLog.setTelecentro(telecentro);
return log(eLog);
}