Fields Summary |
---|
public static final String | TOPLINK_NAMESPACEStores the default session name in case there is the session name is missing. |
public static final String | DEFAULT_TOPLINK_NAMESPACE |
public static final String | SESSION_TOPLINK_NAMESPACE |
private static final Level[] | levelsStores all the java.util.logging.Levels. The indexes are TopLink logging levels. |
private static Logger | defaultTopLinkLoggerStores the Logger for default TopLink namespace, i.e. "oracle.toplink.essentials".
This namespace should be a child of the TopLink namespace, e.g.
"oracle.toplink.essentials.default", otherwise AbstractSessionLog will set the explicit
level for all TopLink loggers (overriding the container settings) in the VM on
the first PU with the specified log level. |
private Map | nameSpaceMapRepresents the HashMap that stores all the name space strings.
The keys are category names. The values are namespace strings. |
private String | sessionNameSpaceStores the namespace for session, i.e."oracle.toplink.essentials.session.". |
private Logger | sessionLoggerStores the Logger for session namespace, i.e. "oracle.toplink.essentials.session.". |
private Map | categoryloggers |
Methods Summary |
---|
public java.lang.Object | clone()INTERNAL:
Each session owns its own session log because session is stored in the session log
// There is no special treatment required for cloning here
// The state of this object is described by member variables sessionLogger and categoryLoggers.
// This state depends on session.
// If session for the clone is going to be the same as session for this there is no
// need to do "deep" cloning.
// If not, the session being cloned should call setSession() on its JavaLog object to initialize it correctly.
JavaLog cloneLog = (JavaLog)super.clone();
return cloneLog;
|
private java.util.logging.Level | getJavaLevel(int level)INTERNAL:
Return the corresponding java.util.logging.Level for a given TopLink level.
return levels[level];
|
public int | getLevel(java.lang.String category)PUBLIC:
Return the effective log level for the name space extracted from session and category.
If a Logger's level is set to be null then the Logger will use an effective Level that will
be obtained by walking up the parent tree and using the first non-null Level.
Logger logger = getLogger(category);
while ((logger != null) && (logger.getLevel() == null)) {
logger = logger.getParent();
}
if (logger == null) {
return OFF;
}
//For a given java.util.logging.Level, return the index (ie, TopLink logging level)
int logLevel = logger.getLevel().intValue();
for (int i = 0; i < levels.length ; i++) {
if (logLevel == levels[i].intValue()) {
return i;
}
}
return OFF;
|
protected java.util.logging.Logger | getLogger(java.lang.String category)INTERNAL:
Return the Logger for the given category
if (session == null) {
return defaultTopLinkLogger;
} else if ((category == null) || (category.length() == 0)) {
return sessionLogger;
} else {
Logger logger = (Logger) categoryloggers.get(category);
// If session != null, categoryloggers should have an entry for this category
assert logger != null;
return logger;
}
|
protected java.lang.String | getNameSpaceString(java.lang.String category)INTERNAL:
Return the name space for the given category from the map.
if (session == null) {
return DEFAULT_TOPLINK_NAMESPACE;
} else if ((category == null) || (category.length() == 0)) {
return sessionNameSpace;
} else {
return (String)nameSpaceMap.get(category);
}
|
protected void | internalLog(oracle.toplink.essentials.logging.SessionLogEntry entry, java.util.logging.Level javaLevel, java.util.logging.Logger logger)INTERNAL:
Build a LogRecord
// 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 void | log(oracle.toplink.essentials.logging.SessionLogEntry entry)PUBLIC:
Log a SessionLogEntry
if (!shouldLog(entry.getLevel(), entry.getNameSpace())) {
return;
}
Logger logger = getLogger(entry.getNameSpace());
Level javaLevel = getJavaLevel(entry.getLevel());
internalLog(entry, javaLevel, logger);
|
public void | setLevel(int level, java.lang.String category)PUBLIC:
Set the log level to a logger with name space extracted from the given category.
final Logger logger = getLogger(category);
if (logger == null) {
return;
}
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
logger.setLevel(getJavaLevel(level));
return null; // nothing to return
}
});
|
public void | setSession(oracle.toplink.essentials.sessions.Session session)PUBLIC:
Set the session and session namespace.
super.setSession(session);
if (session != null) {
String sessionName = session.getName();
if ((sessionName != null) && (sessionName.length() != 0)) {
sessionNameSpace = SESSION_TOPLINK_NAMESPACE + "." + sessionName;
} else {
sessionNameSpace = DEFAULT_TOPLINK_NAMESPACE;
}
//Initialize loggers eagerly
sessionLogger = Logger.getLogger(sessionNameSpace);
for (int i = 0; i < loggerCategories.length; i++) {
String loggerCategory = loggerCategories[i];
String loggerNameSpace = sessionNameSpace + "." + loggerCategory;
nameSpaceMap.put(loggerCategory, loggerNameSpace);
categoryloggers.put(loggerCategory, Logger.getLogger(loggerNameSpace));
}
}
|
public boolean | shouldLog(int level, java.lang.String category)PUBLIC:
Check if a message of the given level would actually be logged by the logger
with name space built from the given session and category.
Return the shouldLog for the given category from
Logger logger = getLogger(category);
return logger.isLoggable(getJavaLevel(level));
|
public void | throwing(java.lang.Throwable throwable)PUBLIC:
Log a throwable.
getLogger(null).throwing(null, null, throwable);
|