public abstract class AbstractSessionLog extends Object implements SessionLog, Cloneable
SessionLog
,
SessionLogEntry
,
DefaultSessionLog
,
JavaLog
Modifier and Type | Field and Description |
---|---|
protected static String |
CONFIG_PREFIX
Represents prefix to logged config
|
protected static String |
CONNECTION_STRING
Connection string
|
protected DateFormat |
dateFormat
Format use to print the current date/time.
|
protected static SessionLog |
defaultLog
Represents the singleton SessionLog
|
protected static String |
FINE_PREFIX
Represents prefix to logged fine
|
protected static String |
FINER_PREFIX
Represents prefix to logged finer
|
protected static String |
FINEST_PREFIX
Represents prefix to logged finest
|
protected static String |
INFO_PREFIX
Represents prefix to logged info
|
protected int |
level
Represents the log level
|
protected Session |
session
Represents the session that owns this SessionLog
|
protected String |
sessionHashCode
Caches the session hash code string of the session that owns this SessionLog
|
protected String |
sessionType
Represents the session type of the session that owns this SessionLog
|
protected static String |
SEVERE_PREFIX
Represents prefix to logged severe
|
protected Boolean |
shouldLogExceptionStackTrace
Allows the printing of the stack to be explictitly disabled/enabled.
|
protected Boolean |
shouldPrintConnection
Allows the printing of the connection to be explictitly disabled/enabled.
|
protected Boolean |
shouldPrintDate
Allows the printing of the date to be explictitly disabled/enabled.
|
protected Boolean |
shouldPrintSession
Allows the printing of the session to be explictitly disabled/enabled.
|
protected Boolean |
shouldPrintThread
Allows the printing of the thread to be explictitly disabled/enabled.
|
protected static String |
THREAD_STRING
Thread string
|
protected static String |
TOPLINK_PREFIX
Cached TopLink prefix string.
|
protected static String |
WARNING_PREFIX
Represents prefix to logged warning
|
protected Writer |
writer
Represents the writer that will receive the formatted log entries
|
ALL, CACHE, CONFIG, CONNECTION, DMS, EJB, EJB_OR_METADATA, EVENT, FINE, FINER, FINEST, INFO, loggerCategories, OFF, PROPAGATION, PROPERTIES, QUERY, SEQUENCING, SEVERE, SQL, TRANSACTION, WARNING, WEAVER
Constructor and Description |
---|
AbstractSessionLog()
PUBLIC:
Create a new AbstractSessionLog
|
Modifier and Type | Method and Description |
---|---|
protected DateFormat |
buildDefaultDateFormat()
Build and return a date format.
|
protected void |
buildSessionHashCode()
Return the current session hash code.
|
protected void |
buildSessionType()
Return the current session type.
|
Object |
clone()
INTERNAL:
Each session owns its own session log because session is stored in the session log
|
void |
config(String message)
PUBLIC:
|
void |
fine(String message)
PUBLIC:
|
void |
finer(String message)
PUBLIC:
|
void |
finest(String message)
PUBLIC:
|
protected String |
formatMessage(SessionLogEntry entry)
Return the formatted message based on the information from the given SessionLogEntry.
|
protected String |
getConnectionString(Accessor connection)
Return the specified connection information.
|
DateFormat |
getDateFormat()
PUBLIC:
Return the date format to be used when printing a log entry date.
|
protected String |
getDateString(Date date)
Return the specified date and/or time information in string.
|
int |
getLevel()
PUBLIC:
|
int |
getLevel(String category)
PUBLIC:
|
static SessionLog |
getLog()
PUBLIC:
|
Session |
getSession()
PUBLIC:
|
protected String |
getSessionString()
Return the current session including the type and id.
|
protected String |
getSessionString(Session session)
Return the current session including the type and id.
|
protected String |
getSupplementDetailString(SessionLogEntry entry)
Return the supplement detail information including date, session, thread and connection.
|
protected String |
getThreadString(Thread thread)
Return the specified thread information.
|
Writer |
getWriter()
PUBLIC:
|
void |
info(String message)
PUBLIC:
|
boolean |
isOff()
PUBLIC:
Check if the log level is set to off.
|
void |
log(int level,
String message)
PUBLIC:
|
void |
log(int level,
String message,
Object param)
INTERNAL:
|
void |
log(int level,
String message,
Object[] params)
INTERNAL:
|
void |
log(int level,
String message,
Object[] params,
boolean shouldTranslate)
INTERNAL:
|
void |
log(int level,
String message,
Object param1,
Object param2)
INTERNAL:
|
void |
log(int level,
String message,
Object param1,
Object param2,
Object param3)
INTERNAL:
|
abstract void |
log(SessionLogEntry sessionLogEntry)
PUBLIC:
|
void |
logThrowable(int level,
Throwable throwable)
PUBLIC:
|
protected void |
printPrefixString(int level)
Print the prefix string representing TopLink logging
|
void |
setDateFormat(DateFormat dateFormat)
PUBLIC:
Set the date format to be used when
printing a log entry date.
|
void |
setLevel(int level)
PUBLIC:
|
void |
setLevel(int level,
String category)
PUBLIC:
|
static void |
setLog(SessionLog sessionLog)
PUBLIC:
|
void |
setSession(Session session)
PUBLIC:
|
void |
setShouldLogExceptionStackTrace(boolean shouldLogExceptionStackTrace)
By default the stack is logged for FINER or less (finest).
|
void |
setShouldPrintConnection(boolean shouldPrintConnection)
By default the connection is printed, this can be turned off.
|
void |
setShouldPrintDate(boolean shouldPrintDate)
By default the date is always printed, but can be turned off.
|
void |
setShouldPrintSession(boolean shouldPrintSession)
By default the session (and its connection is available) are printed,
this can be turned off.
|
void |
setShouldPrintThread(boolean shouldPrintThread)
By default the thread is logged for FINE or less (finer,etc.).
|
void |
setWriter(Writer writer)
PUBLIC:
|
void |
severe(String message)
PUBLIC:
|
boolean |
shouldLog(int level)
PUBLIC:
|
boolean |
shouldLog(int level,
String category)
PUBLIC:
|
boolean |
shouldLogExceptionStackTrace()
By default the stack is logged for FINER or less (finest).
|
boolean |
shouldPrintConnection()
By default the connection is printed, this can be turned off.
|
boolean |
shouldPrintDate()
By default the date is always printed, but can be turned off.
|
boolean |
shouldPrintSession()
By default the session (and its connection is available) are printed,
this can be turned off.
|
boolean |
shouldPrintThread()
By default the thread is logged for FINE or less (finer,etc.).
|
void |
throwing(Throwable throwable)
PUBLIC:
|
static String |
translateLoggingLevelToString(int loggingLevel)
INTERNAL:
Translate the string value of the log level to the constant value.
|
static int |
translateStringToLoggingLevel(String loggingLevel)
INTERNAL:
Translate the string value of the log level to the constant value.
|
void |
warning(String message)
PUBLIC:
|
protected int level
protected static SessionLog defaultLog
protected Session session
protected String sessionType
protected String sessionHashCode
protected static String SEVERE_PREFIX
protected static String WARNING_PREFIX
protected static String INFO_PREFIX
protected static String CONFIG_PREFIX
protected static String FINE_PREFIX
protected static String FINER_PREFIX
protected static String FINEST_PREFIX
protected static String TOPLINK_PREFIX
protected static String CONNECTION_STRING
protected static String THREAD_STRING
protected Writer writer
protected DateFormat dateFormat
protected Boolean shouldLogExceptionStackTrace
protected Boolean shouldPrintDate
protected Boolean shouldPrintThread
protected Boolean shouldPrintSession
protected Boolean shouldPrintConnection
public AbstractSessionLog()
public int getLevel()
Return the log level. It is used when session is not available.
getLevel
in interface SessionLog
public int getLevel(String category)
Return the log level. Category is only needed in JavaLog to extract name space for the Logger which the log level belongs to.
getLevel
in interface SessionLog
category
- the string representation of a TopLink category, e.g. "sql", "transaction" ...
public void setLevel(int level)
Set the log level. It is used when session is not available.
setLevel
in interface SessionLog
level
- the new log level
public void setLevel(int level, String category)
Set the log level. Category is only needed in JavaLog to extract name space for the Logger which the log level belongs to.
setLevel
in interface SessionLog
level
- the new log levelcategory
- the string representation of a TopLink category, e.g. "sql", "transaction" ...
public boolean shouldLog(int level)
Check if a message of the given level would actually be logged. It is used when session is not available.
shouldLog
in interface SessionLog
level
- the log request level
public boolean shouldLog(int level, String category)
Check if a message of the given level would actually be logged. Category is only needed in JavaLog to extract name space for the Logger which the log level belongs to. !isOff() is checked to screen out the possibility when both log level and log request level are set to OFF.
shouldLog
in interface SessionLog
level
- the log request levelcategory
- the string representation of a TopLink category, e.g. "sql", "transaction" ...*
public static SessionLog getLog()
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.
public static void setLog(SessionLog sessionLog)
Set the singleton SessionLog.
sessionLog
- a SessionLog
public Session getSession()
Get the session.
getSession
in interface SessionLog
public void setSession(Session session)
Set the session.
setSession
in interface SessionLog
session
- a Session
public void log(int level, String message)
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.
log
in interface SessionLog
level
- the log request level value
message
- the string message
public void log(int level, String message, Object param)
Log a message with one parameter that needs to be translated.
log
in interface SessionLog
level
- the log request level value
message
- the string message
param
- a parameter of the message
public void log(int level, String message, Object param1, Object param2)
Log a message with two parameters that needs to be translated.
log
in interface SessionLog
level
- the log request level value
message
- the string message
param1
- a parameter of the message
param2
- second parameter of the message
public void log(int level, String message, Object param1, Object param2, Object param3)
Log a message with three parameters that needs to be translated.
log
in interface SessionLog
level
- the log request level value
message
- the string message
param1
- a parameter of the message
param2
- second parameter of the message
param3
- third parameter of the message
public void log(int level, String message, Object[] params)
Log a message with an array of parameters that needs to be translated.
log
in interface SessionLog
level
- the log request level value
message
- the string message
params
- array of parameters to the message
public void log(int level, String message, Object[] params, boolean shouldTranslate)
Log a message. shouldTranslate determines if the message needs to be translated.
log
in interface SessionLog
level
- the log request level
message
- the string message
params
- array of parameters to the message
shouldTranslate
- true if the message needs to be translated
public abstract void log(SessionLogEntry sessionLogEntry)
Log a SessionLogEntry
log
in interface SessionLog
entry
- SessionLogEntry that holds all the information for a TopLink logging event
public boolean shouldPrintSession()
shouldPrintSession
in interface SessionLog
public void setShouldPrintSession(boolean shouldPrintSession)
setShouldPrintSession
in interface SessionLog
public boolean shouldPrintConnection()
shouldPrintConnection
in interface SessionLog
public void setShouldPrintConnection(boolean shouldPrintConnection)
setShouldPrintConnection
in interface SessionLog
public boolean shouldLogExceptionStackTrace()
shouldLogExceptionStackTrace
in interface SessionLog
public void setShouldLogExceptionStackTrace(boolean shouldLogExceptionStackTrace)
setShouldLogExceptionStackTrace
in interface SessionLog
public boolean shouldPrintDate()
shouldPrintDate
in interface SessionLog
public void setShouldPrintDate(boolean shouldPrintDate)
setShouldPrintDate
in interface SessionLog
public boolean shouldPrintThread()
shouldPrintThread
in interface SessionLog
public void setShouldPrintThread(boolean shouldPrintThread)
setShouldPrintThread
in interface SessionLog
public Writer getWriter()
Return the writer that will receive the formatted log entries.
getWriter
in interface SessionLog
public void setWriter(Writer writer)
Set the writer that will receive the formatted log entries.
setWriter
in interface SessionLog
writer
- the log writer
protected DateFormat buildDefaultDateFormat()
public DateFormat getDateFormat()
protected String getDateString(Date date)
protected String getSupplementDetailString(SessionLogEntry entry)
protected String getSessionString(Session session)
protected void buildSessionType()
protected void buildSessionHashCode()
protected String getSessionString()
protected String getConnectionString(Accessor connection)
protected String getThreadString(Thread thread)
protected void printPrefixString(int level)
public void setDateFormat(DateFormat dateFormat)
dateFormat
- java.text.DateFormatprotected String formatMessage(SessionLogEntry entry)
public void throwing(Throwable throwable)
Log a throwable at FINER level.
throwing
in interface SessionLog
throwable
- a Throwable
public static int translateStringToLoggingLevel(String loggingLevel)
public static String translateLoggingLevelToString(int loggingLevel)
public void severe(String message)
This method is called when a severe level message needs to be logged. The message will be translated
severe
in interface SessionLog
message
- the message key
public void warning(String message)
This method is called when a warning level message needs to be logged. The message will be translated
warning
in interface SessionLog
message
- the message key
public void info(String message)
This method is called when a info level message needs to be logged. The message will be translated
info
in interface SessionLog
message
- the message key
public void config(String message)
This method is called when a config level message needs to be logged. The message will be translated
config
in interface SessionLog
message
- the message key
public void fine(String message)
This method is called when a fine level message needs to be logged. The message will be translated
fine
in interface SessionLog
message
- the message key
public void finer(String message)
This method is called when a finer level message needs to be logged. The message will be translated
finer
in interface SessionLog
message
- the message key
public void finest(String message)
This method is called when a finest level message needs to be logged. The message will be translated
finest
in interface SessionLog
message
- the message key
public void logThrowable(int level, Throwable throwable)
Log a throwable with level.
logThrowable
in interface SessionLog
level
- the log request level value
throwable
- a Throwable
public boolean isOff()
Copyright © 2024. All rights reserved.