Fields Summary |
---|
protected int | levelRepresents the log level |
protected static SessionLog | defaultLogRepresents the singleton SessionLog |
protected Session | sessionRepresents the session that owns this SessionLog |
protected String | sessionTypeRepresents the session type of the session that owns this SessionLog |
protected String | sessionHashCodeCaches the session hash code string of the session that owns this SessionLog |
protected static String | SEVERE_PREFIXRepresents prefix to logged severe |
protected static String | WARNING_PREFIXRepresents prefix to logged warning |
protected static String | INFO_PREFIXRepresents prefix to logged info |
protected static String | CONFIG_PREFIXRepresents prefix to logged config |
protected static String | FINE_PREFIXRepresents prefix to logged fine |
protected static String | FINER_PREFIXRepresents prefix to logged finer |
protected static String | FINEST_PREFIXRepresents prefix to logged finest |
protected static String | TOPLINK_PREFIXCached TopLink prefix string. |
protected static final String | CONNECTION_STRINGConnection string |
protected static final String | THREAD_STRINGThread string |
protected Writer | writerRepresents the writer that will receive the formatted log entries |
protected DateFormat | dateFormatFormat use to print the current date/time. |
protected Boolean | shouldLogExceptionStackTraceAllows the printing of the stack to be explictitly disabled/enabled.
CR #3870467.
null value is default behavoir of determining from log level. |
protected Boolean | shouldPrintDateAllows the printing of the date to be explictitly disabled/enabled.
CR #3870467.
null value is default behavoir of determining from log level. |
protected Boolean | shouldPrintThreadAllows the printing of the thread to be explictitly disabled/enabled.
CR #3870467.
null value is default behavoir of determining from log level. |
protected Boolean | shouldPrintSessionAllows the printing of the session to be explictitly disabled/enabled.
CR #3870467.
null value is default behavoir of determining from log level. |
protected Boolean | shouldPrintConnectionAllows the printing of the connection to be explictitly disabled/enabled.
CR #4157545.
null value is default behavoir of determining from log level. |
Methods Summary |
---|
protected java.text.DateFormat | buildDefaultDateFormat()Build and return a date format.
The default is a format that is sortable and easily parsed.
return new SimpleDateFormat("yyyy.MM.dd hh:mm:ss.SSS");
|
protected void | buildSessionHashCode()Return the current session hash code.
if (session != null) {
sessionHashCode = String.valueOf(System.identityHashCode(session));
} else {
sessionHashCode = null;
}
|
protected void | buildSessionType()Return the current session type.
if (session != null) {
sessionType = ((AbstractSession)session).getSessionTypeString();
} else {
sessionType = null;
}
|
public java.lang.Object | clone()INTERNAL:
Each session owns its own session log because session is stored in the session log
try {
return super.clone();
} catch (Exception exception) {
return null;
}
|
public void | config(java.lang.String message)PUBLIC:
This method is called when a config level message needs to be logged.
The message will be translated
log(CONFIG, message, (Object[])null);
|
public void | fine(java.lang.String message)PUBLIC:
This method is called when a fine level message needs to be logged.
The message will be translated
log(FINE, message, (Object[])null);
|
public void | finer(java.lang.String message)PUBLIC:
This method is called when a finer level message needs to be logged.
The message will be translated
log(FINER, message, (Object[])null);
|
public void | finest(java.lang.String message)PUBLIC:
This method is called when a finest level message needs to be logged.
The message will be translated
log(FINEST, message, (Object[])null);
|
protected java.lang.String | formatMessage(oracle.toplink.essentials.logging.SessionLogEntry entry)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.
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;
|
protected java.lang.String | getConnectionString(oracle.toplink.essentials.internal.databaseaccess.Accessor connection)Return the specified connection information.
// Bug 3630182 - if possible, print the actual connection's hashcode instead of just the accessor
if (connection.getDatasourceConnection() == null){
return CONNECTION_STRING + "(" + String.valueOf(System.identityHashCode(connection)) + ")";
} else {
return CONNECTION_STRING + "(" + String.valueOf(System.identityHashCode(connection.getDatasourceConnection())) + ")";
}
|
public java.text.DateFormat | getDateFormat()PUBLIC:
Return the date format to be used when printing a log entry date.
if (dateFormat == null) {
dateFormat = this.buildDefaultDateFormat();
}
return dateFormat;
|
protected java.lang.String | getDateString(java.util.Date date)Return the specified date and/or time information in string.
The format will be determined by the date format settings.
return this.getDateFormat().format(date);
|
public int | getLevel()PUBLIC:
Return the log level. It is used when session is not available.
return getLevel(null);
|
public int | getLevel(java.lang.String category)PUBLIC:
Return the log level for the category name space.
return level;
|
public static oracle.toplink.essentials.logging.SessionLog | getLog()PUBLIC:
Return the singleton SessionLog. If the singleton SessionLog does not exist,
a new one is created based on the version of JDK being used from the Version class.
if (defaultLog == null) {
defaultLog = new DefaultSessionLog();
}
return defaultLog;
|
public oracle.toplink.essentials.sessions.Session | getSession()PUBLIC:
Get the session.
return this.session;
|
protected java.lang.String | getSessionString(oracle.toplink.essentials.sessions.Session session)Return the current session including the type and id.
// For bug 3422759 the session to log against should be the one in the
// event, not the static one in the SessionLog, for there are many
// sessions but only one SessionLog.
if (session != null) {
return ((AbstractSession)session).getLogSessionString();
} else {
return getSessionString();
}
|
protected java.lang.String | getSessionString()Return the current session including the type and id.
return sessionType + "(" + sessionHashCode + ")";
|
protected java.lang.String | getSupplementDetailString(oracle.toplink.essentials.logging.SessionLogEntry entry)Return the supplement detail information including date, session, thread and connection.
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();
|
protected java.lang.String | getThreadString(java.lang.Thread thread)Return the specified thread information.
return THREAD_STRING + "(" + String.valueOf(thread) + ")";
|
public java.io.Writer | getWriter()PUBLIC:
Return the writer that will receive the formatted log entries.
return writer;
|
public void | info(java.lang.String message)PUBLIC:
This method is called when a info level message needs to be logged.
The message will be translated
log(INFO, message, (Object[])null);
|
public boolean | isOff()PUBLIC:
Check if the log level is set to off.
return this.level == OFF;
|
public void | log(int level, java.lang.String message)PUBLIC:
Log a message that does not need to be translated. This method is intended for
external use when logging messages are wanted within the TopLink output.
if (!shouldLog(level)) {
return;
}
//Bug#4566524 Pass in false for external use
log(level, message, (Object[])null, false);
|
public void | log(int level, java.lang.String message, java.lang.Object param)INTERNAL:
Log a message with one parameter that needs to be translated.
if (!shouldLog(level)) {
return;
}
log(level, message, new Object[] { param });
|
public void | log(int level, java.lang.String message, java.lang.Object param1, java.lang.Object param2)INTERNAL:
Log a message with two parameters that needs to be translated.
if (!shouldLog(level)) {
return;
}
log(level, message, new Object[] { param1, param2 });
|
public void | log(int level, java.lang.String message, java.lang.Object param1, java.lang.Object param2, java.lang.Object param3)INTERNAL:
Log a message with three parameters that needs to be translated.
if (!shouldLog(level)) {
return;
}
log(level, message, new Object[] { param1, param2, param3 });
|
public void | log(int level, java.lang.String message, java.lang.Object[] params)INTERNAL:
Log a message with an array of parameters that needs to be translated.
log(level, message, params, true);
|
public void | log(int level, java.lang.String message, java.lang.Object[] params, boolean shouldTranslate)INTERNAL:
Log a message. shouldTranslate determines if the message needs to be translated.
if (!shouldLog(level)) {
return;
}
log(new SessionLogEntry(level, null, message, params, null, shouldTranslate));
|
public abstract void | log(oracle.toplink.essentials.logging.SessionLogEntry sessionLogEntry)PUBLIC:
Log a SessionLogEntry
|
public void | logThrowable(int level, java.lang.Throwable throwable)PUBLIC:
Log a throwable with level.
// Must not create the log if not logging as is a performance issue.
if (shouldLog(level)) {
log(new SessionLogEntry(null, level, null, throwable));
}
|
protected void | printPrefixString(int level)Print the prefix string representing TopLink logging
try {
switch (level) {
case SEVERE:
if (SEVERE_PREFIX == null) {
SEVERE_PREFIX = LoggingLocalization.buildMessage("toplink_severe");
}
this.getWriter().write(SEVERE_PREFIX);
break;
case WARNING:
if (WARNING_PREFIX == null) {
WARNING_PREFIX = LoggingLocalization.buildMessage("toplink_warning");
}
this.getWriter().write(WARNING_PREFIX);
break;
case INFO:
if (INFO_PREFIX == null) {
INFO_PREFIX = LoggingLocalization.buildMessage("toplink_info");
}
this.getWriter().write(INFO_PREFIX);
break;
case CONFIG:
if (CONFIG_PREFIX == null) {
CONFIG_PREFIX = LoggingLocalization.buildMessage("toplink_config");
}
this.getWriter().write(CONFIG_PREFIX);
break;
case FINE:
if (FINE_PREFIX == null) {
FINE_PREFIX = LoggingLocalization.buildMessage("toplink_fine");
}
this.getWriter().write(FINE_PREFIX);
break;
case FINER:
if (FINER_PREFIX == null) {
FINER_PREFIX = LoggingLocalization.buildMessage("toplink_finer");
}
this.getWriter().write(FINER_PREFIX);
break;
case FINEST:
if (FINEST_PREFIX == null) {
FINEST_PREFIX = LoggingLocalization.buildMessage("toplink_finest");
}
this.getWriter().write(FINEST_PREFIX);
break;
default:
if (TOPLINK_PREFIX == null) {
TOPLINK_PREFIX = LoggingLocalization.buildMessage("toplink");
}
this.getWriter().write(TOPLINK_PREFIX);
}
} catch (IOException exception) {
throw ValidationException.logIOError(exception);
}
|
public void | setDateFormat(java.text.DateFormat dateFormat)PUBLIC:
Set the date format to be used when
printing a log entry date.
this.dateFormat = dateFormat;
|
public void | setLevel(int level)PUBLIC:
Set the log level. It is used when session is not available.
setLevel(level, null);
|
public void | setLevel(int level, java.lang.String category)PUBLIC:
Set the log level for the category name space.
this.level = level;
|
public static void | setLog(oracle.toplink.essentials.logging.SessionLog sessionLog)PUBLIC:
Set the singleton SessionLog.
defaultLog = sessionLog;
defaultLog.setSession(null);
|
public void | setSession(oracle.toplink.essentials.sessions.Session session)PUBLIC:
Set the session.
if (this.session == null) {
this.session = session;
buildSessionType();
buildSessionHashCode();
}
|
public void | setShouldLogExceptionStackTrace(boolean shouldLogExceptionStackTrace)By default the stack is logged for FINER or less (finest).
The logging of the stack can also be explicitly turned on or off.
if (shouldLogExceptionStackTrace) {
this.shouldLogExceptionStackTrace = Boolean.TRUE;
} else {
this.shouldLogExceptionStackTrace = Boolean.FALSE;
}
|
public void | setShouldPrintConnection(boolean shouldPrintConnection)By default the connection is printed, this can be turned off.
if (shouldPrintConnection) {
this.shouldPrintConnection = Boolean.TRUE;
} else {
this.shouldPrintConnection = Boolean.FALSE;
}
|
public void | setShouldPrintDate(boolean shouldPrintDate)By default the date is always printed, but can be turned off.
if (shouldPrintDate) {
this.shouldPrintDate = Boolean.TRUE;
} else {
this.shouldPrintDate = Boolean.FALSE;
}
|
public void | setShouldPrintSession(boolean shouldPrintSession)By default the session (and its connection is available) are printed,
this can be turned off.
if (shouldPrintSession) {
this.shouldPrintSession = Boolean.TRUE;
} else {
this.shouldPrintSession = Boolean.FALSE;
}
|
public void | setShouldPrintThread(boolean shouldPrintThread)By default the thread is logged for FINE or less (finer,etc.).
The logging of the thread can also be explicitly turned on or off.
if (shouldPrintThread) {
this.shouldPrintThread = Boolean.TRUE;
} else {
this.shouldPrintThread = Boolean.FALSE;
}
|
public void | setWriter(java.io.Writer writer)PUBLIC:
Set the writer that will receive the formatted log entries.
this.writer = writer;
|
public void | severe(java.lang.String message)PUBLIC:
This method is called when a severe level message needs to be logged.
The message will be translated
log(SEVERE, message, (Object[])null);
|
public boolean | shouldLog(int level)PUBLIC:
Check if a message of the given level would actually be logged.
It is used when session is not available.
return shouldLog(level, null);
|
public boolean | shouldLog(int level, java.lang.String category)PUBLIC:
Check if a message of the given level would actually be logged for the category name space.
!isOff() is checked to screen out the possibility when both
log level and log request level are set to OFF.
return (this.level <= level) && !isOff();
|
public boolean | shouldLogExceptionStackTrace()By default the stack is logged for FINER or less (finest).
The logging of the stack can also be explicitly turned on or off.
if (shouldLogExceptionStackTrace == null) {
return getLevel() <= FINER;
} else {
return shouldLogExceptionStackTrace.booleanValue();
}
|
public boolean | shouldPrintConnection()By default the connection is printed, this can be turned off.
return (shouldPrintConnection == null) || shouldPrintConnection.booleanValue();
|
public boolean | shouldPrintDate()By default the date is always printed, but can be turned off.
return (shouldPrintDate == null) || (shouldPrintDate.booleanValue());
|
public boolean | shouldPrintSession()By default the session (and its connection is available) are printed,
this can be turned off.
return (shouldPrintSession == null) || shouldPrintSession.booleanValue();
|
public boolean | shouldPrintThread()By default the thread is logged for FINE or less (finer,etc.).
The logging of the thread can also be explicitly turned on or off.
if (shouldPrintThread == null) {
return getLevel() <= FINE;
} else {
return shouldPrintThread.booleanValue();
}
|
public void | throwing(java.lang.Throwable throwable)PUBLIC:
Log a throwable at FINER level.
if (shouldLog(FINER)) {
SessionLogEntry entry = new SessionLogEntry(null, throwable);
entry.setLevel(FINER);
log(entry);
}
|
public static java.lang.String | translateLoggingLevelToString(int loggingLevel)INTERNAL:
Translate the string value of the log level to the constant value.
If value is null or invalid use the default.
if (loggingLevel == OFF){
return "OFF";
} else if (loggingLevel == SEVERE){
return "SEVERE";
} else if (loggingLevel == WARNING){
return "WARNING";
} else if (loggingLevel == INFO){
return "INFO";
} else if (loggingLevel == CONFIG){
return "CONFIG";
} else if (loggingLevel == FINE){
return "FINE";
} else if (loggingLevel == FINER){
return "FINER";
} else if (loggingLevel == FINEST){
return "FINEST";
} else if (loggingLevel == ALL){
return "ALL";
}
return "INFO";
|
public static int | translateStringToLoggingLevel(java.lang.String loggingLevel)INTERNAL:
Translate the string value of the log level to the constant value.
If value is null or invalid use the default.
if (loggingLevel == null){
return INFO;
} else if (loggingLevel.equals("OFF")){
return OFF;
} else if (loggingLevel.equals("SEVERE")){
return SEVERE;
} else if (loggingLevel.equals("WARNING")){
return WARNING;
} else if (loggingLevel.equals("INFO")){
return INFO;
} else if (loggingLevel.equals("CONFIG")){
return CONFIG;
} else if (loggingLevel.equals("FINE")){
return FINE;
} else if (loggingLevel.equals("FINER")){
return FINER;
} else if (loggingLevel.equals("FINEST")){
return FINEST;
} else if (loggingLevel.equals("ALL")){
return ALL;
}
return INFO;
|
public void | warning(java.lang.String message)PUBLIC:
This method is called when a warning level message needs to be logged.
The message will be translated
log(WARNING, message, (Object[])null);
|