/** * PUBLIC: * <p> * Log a throwable at FINER level. * </p><p> * * @param throwable a Throwable * </p> */ public void throwing(Throwable throwable) { if (shouldLog(FINER)) { SessionLogEntry entry = new SessionLogEntry(null, throwable); entry.setLevel(FINER); log(entry); } }
/** * Return the supplement detail information including date, session, thread and connection. */ protected String getSupplementDetailString(SessionLogEntry entry) { StringWriter writer = new StringWriter(); if (shouldPrintDate()) { writer.write(getDateString(entry.getDate())); writer.write("--"); } if (shouldPrintSession() && (entry.getSession() != null)) { writer.write(this.getSessionString(entry.getSession())); writer.write("--"); } if (shouldPrintConnection() && (entry.getConnection() != null)) { writer.write(this.getConnectionString(entry.getConnection())); writer.write("--"); } if (shouldPrintThread()) { writer.write(this.getThreadString(entry.getThread())); writer.write("--"); } return writer.toString(); }
/** * PUBLIC: * <p> * Log a SessionLogEntry * </p><p> * * @param entry SessionLogEntry that holds all the information for a TopLink logging event * </p> */ public void log(SessionLogEntry entry) { if (!shouldLog(entry.getLevel())) { return; } String message = getSupplementDetailString(entry); if (entry.hasException()) { message += entry.getException(); } else { message += formatMessage(entry); } basicLog(entry.getLevel(), message); }
/** * Return the formatted message based on the information from the given SessionLogEntry. * The message will either be translated and formatted or formatted only depending * on if the shouldTranslate flag is set to true of false. */ protected String formatMessage(SessionLogEntry entry) { String message = entry.getMessage(); if (entry.shouldTranslate()) { if (entry.getLevel() > FINE) { message = LoggingLocalization.buildMessage(message, entry.getParameters()); } else { message = TraceLocalization.buildMessage(message, entry.getParameters()); } } else { //bug#2988,if there are entry parameters and the string "{0" contained in the message //body, we assume it needs to be formatted. if (entry.getParameters()!=null && entry.getParameters().length>0 && message.indexOf("{0") >= 0) { message = java.text.MessageFormat.format(message, entry.getParameters()); } } return message; }
/** * PUBLIC: * Log the log entry. */ public void log(SessionLogEntry entry) { if (shouldLog(entry.getLevel(), entry.getNameSpace())) { if (entry.getSession() == null) {// Used for proxy session. entry.setSession(this); } getSessionLog().log(entry); } }
/** * PUBLIC: * <p> * Log a SessionLogEntry * </p><p> * @param entry SessionLogEntry that holds all the information for a TopLink logging event * </p> */ public void log(SessionLogEntry entry) { if (!shouldLog(entry.getLevel(), entry.getNameSpace())) { return; } Logger logger = getLogger(entry.getNameSpace()); Level javaLevel = getJavaLevel(entry.getLevel()); internalLog(entry, javaLevel, logger); }
if (!shouldLog(entry.getLevel(), entry.getNameSpace())) { return; printPrefixString(entry.getLevel()); this.getWriter().write(getSupplementDetailString(entry)); if (entry.hasException()) { if (entry.getLevel() == SEVERE) { entry.getException().printStackTrace(new PrintWriter(getWriter())); } else if (entry.getLevel() <= WARNING) { if (shouldLogExceptionStackTrace()) { entry.getException().printStackTrace(new PrintWriter(getWriter())); } else { writeMessage(entry.getException().toString());
/** * INTERNAL: * <p> * Build a LogRecord * </p><p> * @param entry SessionLogEntry that holds all the information for a TopLink logging event * @param javaLevel the message level * </p> */ protected void internalLog(SessionLogEntry entry, Level javaLevel, Logger logger) { // Format message so that we do not depend on the bundle TopLinkLogRecord lr = new TopLinkLogRecord(javaLevel, formatMessage(entry)); lr.setSourceClassName(null); lr.setSourceMethodName(null); lr.setLoggerName(getNameSpaceString(entry.getNameSpace())); if (shouldPrintSession()) { lr.setSessionString(getSessionString(entry.getSession())); } if (shouldPrintConnection()) { lr.setConnection(entry.getConnection()); } lr.setThrown(entry.getException()); lr.setShouldLogExceptionStackTrace(shouldLogExceptionStackTrace()); lr.setShouldPrintDate(shouldPrintDate()); lr.setShouldPrintThread(shouldPrintThread()); logger.log(lr); }
/** * PUBLIC: * <p> * Log a throwable with level. * </p><p> * * @param level the log request level value * </p><p> * @param throwable a Throwable * </p> */ public void logThrowable(int level, Throwable throwable) { // Must not create the log if not logging as is a performance issue. if (shouldLog(level)) { log(new SessionLogEntry(null, level, null, throwable)); } }
/** * PUBLIC: * Return if the log entry was for an exception. */ public boolean hasException() { return getException() != null; }
/** * PUBLIC: * Print message. */ public String toString() { return oracle.toplink.essentials.internal.helper.Helper.getShortClassName(getClass()) + "(" + getMessage() + ")"; } }
/** * INTERNAL: * <p> * Log a message. shouldTranslate determines if the message needs to be translated. * </p><p> * * @param level the log request level * </p><p> * @param message the string message * </p><p> * @param params array of parameters to the message * </p><p> * @param shouldTranslate true if the message needs to be translated * </p> */ public void log(int level, String message, Object[] params, boolean shouldTranslate) { if (!shouldLog(level)) { return; } log(new SessionLogEntry(level, null, message, params, null, shouldTranslate)); }
/** * PUBLIC: * <p> * Log a throwable with level and category. * </p><p> * * @param level the log request level value * </p><p> * @param category the string representation of a TopLink category. * </p><p> * @param throwable a Throwable * </p> */ public void logThrowable(int level, String category, Throwable throwable) { // Must not create the log if not logging as is a performance issue. if (shouldLog(level, category)) { startOperationProfile(SessionProfiler.Logging); log(new SessionLogEntry(this, level, category, throwable)); endOperationProfile(SessionProfiler.Logging); } }
/** * INTERNAL: * <p> * Log a message with level, parameters and accessor. shouldTranslate determines if the message needs to be translated. * </p><p> * * @param level the log request level value * </p><p> * @param message the string message * </p><p> * @param params array of parameters to the message * </p><p> * @param accessor the connection that generated the log entry * </p><p> * @param shouldTranslate true if the message needs to be translated. * </p> */ public void log(int level, String message, Object[] params, Accessor accessor, boolean shouldTranslate) { if (shouldLog(level, null)) { startOperationProfile(SessionProfiler.Logging); log(new SessionLogEntry(level, this, message, params, accessor, shouldTranslate)); endOperationProfile(SessionProfiler.Logging); } }
/** * INTERNAL: * <p> * Log a message with level, category, parameters and accessor. shouldTranslate determines if the message needs to be translated. * </p><p> * * @param level the log request level value * </p><p> * @param message the string message * </p><p> * @param params array of parameters to the message * </p><p> * @param accessor the connection that generated the log entry * </p><p> * @param category the string representation of a TopLink category. * </p><p> * @param shouldTranslate true if the message needs to be translated. * </p> */ public void log(int level, String category, String message, Object[] params, Accessor accessor, boolean shouldTranslate) { if (shouldLog(level, category)) { startOperationProfile(SessionProfiler.Logging); log(new SessionLogEntry(level, category, this, message, params, accessor, shouldTranslate)); endOperationProfile(SessionProfiler.Logging); } }
uow.log(new SessionLogEntry(uow, SessionLog.WARNING, SessionLog.TRANSACTION, exception));
uow.log(new SessionLogEntry(uow, SessionLog.WARNING, SessionLog.TRANSACTION, rtEx));