| java.lang.Object java.util.logging.Logger org.geotools.util.logging.LoggerAdapter
All known Subclasses: org.geotools.util.logging.Log4JLogger, org.geotools.util.logging.CommonsLogger,
LoggerAdapter | abstract public class LoggerAdapter extends Logger (Code) | | An adapter that redirect all Java logging events to an other logging framework. This
class redefines the
LoggerAdapter.severe(String) severe ,
LoggerAdapter.warning(String) warning ,
LoggerAdapter.info(String) info ,
LoggerAdapter.config(String) config ,
LoggerAdapter.fine(String) fine ,
LoggerAdapter.finer(String) finer and
LoggerAdapter.finest(String) finest methods as abstract
ones. Subclasses should implement those methods in order to map Java logging levels to
the backend logging framework.
All
LoggerAdapter.log(Level,String) log methods are overriden in order to redirect to one of the
above-cited methods. Note that this is the opposite approach than the Java logging framework
one, which implemented everything on top of
Logger.log(LogRecord) . This adapter is
defined in terms of
LoggerAdapter.severe(String) severe …
LoggerAdapter.finest(String) finest methods instead because external frameworks like
Commons-logging
don't work with
LogRecord , and sometime provides nothing else than convenience methods
equivalent to
LoggerAdapter.severe(String) severe …
LoggerAdapter.finest(String) finest .
Restrictions
Because the configuration is expected to be fully controled by the external logging
framework, every configuration methods inherited from
Logger are disabled:
Since
LoggerAdapter s do not hold any configuration by themself, it is not strictly
necessary to
.
The adapters can be created, garbage-collected and recreated again while preserving their
behavior since their configuration is entirely contained in the external logging framework.
Localization
This logger is always created without resource bundles. Localizations must be performed through
explicit calls to
logrb or
LoggerAdapter.log(LogRecord) methods. This is suffisient for
GeoTools needs, which performs all localizations through the later. Note that those methods
will be slower in this
LoggerAdapter than the default
Logger because this
adapter localizes and formats records immediately instead of letting the
performs this work only if needed.
Logging levels
If a log record
is not one of the predefined ones, then this class
maps to the first level below the specified one. For example if a log record has some level
between
Level.FINE FINE and
Level.FINER FINER , then the
LoggerAdapter.finer finer method will be invoked. See
LoggerAdapter.isLoggable for implementation tips taking advantage of
this rule.
since: 2.4 version: $Id: LoggerAdapter.java 28037 2007-11-24 14:19:24Z aaime $ author: Martin Desruisseaux See Also: Logging |
Method Summary | |
public void | addHandler(Handler handler) Do nothing since this logger adapter does not supports handlers.
The configuration should be fully controlled by the external logging framework
(e.g. | abstract public void | config(String message) Logs an
Level.CONFIG CONFIG message. | public void | entering(String sourceClass, String sourceMethod) Logs a method entry to the
. | public void | entering(String sourceClass, String sourceMethod, Object param) Logs a method entry to the
with one parameter. | public void | entering(String sourceClass, String sourceMethod, Object[] params) Logs a method entry to the
with many parameters. | public void | exiting(String sourceClass, String sourceMethod) Logs a method return to the
. | public void | exiting(String sourceClass, String sourceMethod, Object result) Logs a method return to the
. | abstract public void | fine(String message) Logs a
Level.FINE FINE message. | abstract public void | finer(String message) Logs a
Level.FINER FINER message. | abstract public void | finest(String message) Logs a
Level.FINEST FINEST message. | protected Level | getDebugLevel() Returns the level for
LoggerAdapter.entering ,
LoggerAdapter.exiting and
LoggerAdapter.throwing methods.
The default implementation returns
Level.FINER , which is consistent with the
value used in the Java logging framework. | abstract public Level | getLevel() Returns the level for this logger. | abstract public void | info(String message) Logs an
Level.INFO INFO message. | abstract public boolean | isLoggable(Level level) Returns
true if the specified level is loggable.
Implementation tip
Given that
Level.intValue for all predefined levels are documented in the
Level specification and are multiple of 100, given that integer divisions are rounded toward zero and
given rule documented in this class javadoc, then logging levels can be efficiently mapped to
predefined levels using
switch statements as below. | public void | log(LogRecord record) Logs a record. | public void | log(Level level, String message) Logs a record at the specified level. | public void | log(Level level, String message, Throwable thrown) Logs a record at the specified level. | public void | log(Level level, String message, Object param) Logs a record at the specified level. | public void | log(Level level, String message, Object[] params) Logs a record at the specified level. | public void | logp(Level level, String sourceClass, String sourceMethod, String message) Logs a record at the specified level. | public void | logp(Level level, String sourceClass, String sourceMethod, String message, Throwable thrown) Logs a record at the specified level. | public void | logp(Level level, String sourceClass, String sourceMethod, String message, Object param) Logs a record at the specified level. | public void | logp(Level level, String sourceClass, String sourceMethod, String message, Object[] params) Logs a record at the specified level. | public void | logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message) Logs a localizable record at the specified level. | public void | logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message, Throwable thrown) Logs a localizable record at the specified level. | public void | logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message, Object param) Logs a localizable record at the specified level. | public void | logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message, Object[] params) Logs a localizable record at the specified level. | public void | removeHandler(Handler handler) Do nothing since this logger adapter does not support handlers. | public void | setFilter(Filter filter) Do nothing since this logger adapter does not support filters. | abstract public void | setLevel(Level level) Sets the level for this logger. | public void | setParent(Logger parent) Do nothing since this logger adapter does not support arbitrary parents. | public void | setUseParentHandlers(boolean useParentHandlers) Do nothing since this logger never use parent handlers. | abstract public void | severe(String message) Logs a
Level.SEVERE SEVERE message. | public void | throwing(String sourceClass, String sourceMethod, Throwable thrown) Logs a method failure to the
. | abstract public void | warning(String message) Logs a
Level.WARNING WARNING message. |
LoggerAdapter | protected LoggerAdapter(String name)(Code) | | Creates a new logger.
Parameters: name - The logger name. |
addHandler | public void addHandler(Handler handler)(Code) | | Do nothing since this logger adapter does not supports handlers.
The configuration should be fully controlled by the external logging framework
(e.g. Commons-logging) instead,
which is not expected to use
Handler objects.
|
entering | public void entering(String sourceClass, String sourceMethod)(Code) | | Logs a method entry to the
. Compared to the
default
Logger , this implementation bypass the level check in order to let
the backing logging framework do its own check.
|
entering | public void entering(String sourceClass, String sourceMethod, Object param)(Code) | | Logs a method entry to the
with one parameter.
Compared to the default
Logger , this implementation bypass the level check in
order to let the backing logging framework do its own check.
|
entering | public void entering(String sourceClass, String sourceMethod, Object[] params)(Code) | | Logs a method entry to the
with many parameters.
Compared to the default
Logger , this implementation bypass the level check in
order to let the backing logging framework do its own check.
|
exiting | public void exiting(String sourceClass, String sourceMethod)(Code) | | Logs a method return to the
. Compared to the
default
Logger , this implementation bypass the level check in order to let
the backing logging framework do its own check.
|
exiting | public void exiting(String sourceClass, String sourceMethod, Object result)(Code) | | Logs a method return to the
. Compared to the
default
Logger , this implementation bypass the level check in order to let
the backing logging framework do its own check.
|
getLevel | abstract public Level getLevel()(Code) | | Returns the level for this logger. Subclasses shall get this level from the
external logging framework.
|
isLoggable | abstract public boolean isLoggable(Level level)(Code) | | Returns
true if the specified level is loggable.
Implementation tip
Given that
Level.intValue for all predefined levels are documented in the
Level specification and are multiple of 100, given that integer divisions are rounded toward zero and
given rule documented in this class javadoc, then logging levels can be efficiently mapped to
predefined levels using
switch statements as below. This statement has good chances to
be compiled to the
tableswitch bytecode rather than
lookupswitch (see
Compiling
Switches in The Java Virtual Machine Specification).
"fallthrough")
public boolean isLoggable(Level level) {
final int n = level.intValue();
switch (n / 100) {
default: {
// MAX_VALUE is a special value for Level.OFF. Otherwise and
// if positive, fallthrough since we are greater than SEVERE.
switch (n) {
case Integer.MIN_VALUE: return true; // Level.ALL
case Integer.MAX_VALUE: return false; // Level.OFF
default: if (n < 0) return false;
}
}
case 10: return isSevereEnabled();
case 9: return isWarningEnabled();
case 8: return isInfoEnabled();
case 7: return isConfigEnabled();
case 6: // fallthrough
case 5: return isFineEnabled();
case 4: return isFinerEnabled();
case 3: return isFinestEnabled();
case 2: // fallthrough
case 1: // fallthrough
case 0: return false;
}
}
|
log | public void log(Level level, String message, Throwable thrown)(Code) | | Logs a record at the specified level. The default implementation discards the exception
and delegates to
(level, message) .
|
log | public void log(Level level, String message, Object param)(Code) | | Logs a record at the specified level. The defaut implementation delegates to
(level, message, params)
where the
params array is built from the
param object.
|
log | public void log(Level level, String message, Object[] params)(Code) | | Logs a record at the specified level.
The defaut implementation formats the message immediately, then delegates to
(level, message) .
|
logp | public void logp(Level level, String sourceClass, String sourceMethod, String message)(Code) | | Logs a record at the specified level. The defaut implementation discards
the source class and source method, then delegates to
(level, message) .
|
logp | public void logp(Level level, String sourceClass, String sourceMethod, String message, Throwable thrown)(Code) | | Logs a record at the specified level. The defaut implementation discards
the source class and source method, then delegates to
(level, message, thrown) .
|
logp | public void logp(Level level, String sourceClass, String sourceMethod, String message, Object param)(Code) | | Logs a record at the specified level. The defaut implementation delegates to
(level, sourceClass,
sourceMethod, message, params) where the
params array is built from the
param object.
Note that
sourceClass and
sourceMethod will be discarted unless the
target
LoggerAdapter.logp(Level,String,String,String) logp method has been overriden.
|
logp | public void logp(Level level, String sourceClass, String sourceMethod, String message, Object[] params)(Code) | | Logs a record at the specified level. The defaut implementation formats the message
immediately, then delegates to
(level, sourceClass, sourceMethod, message) .
Note that
sourceClass and
sourceMethod will be discarted unless the
target
LoggerAdapter.logp(Level,String,String,String) logp method has been overriden.
|
logrb | public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message)(Code) | | Logs a localizable record at the specified level. The defaut implementation localizes the
message immediately, then delegates to
(level, sourceClass, sourceMethod, message) .
|
logrb | public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message, Throwable thrown)(Code) | | Logs a localizable record at the specified level. The defaut implementation localizes the
message immediately, then delegates to
(level, sourceClass, sourceMethod, message, thrown) .
|
logrb | public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message, Object param)(Code) | | Logs a localizable record at the specified level. The defaut implementation localizes the
message immediately, then delegates to
(level, sourceClass, sourceMethod, message, param) .
|
logrb | public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String message, Object[] params)(Code) | | Logs a localizable record at the specified level. The defaut implementation localizes the
message immediately, then delegates to
(level, sourceClass, sourceMethod, message, params) .
|
removeHandler | public void removeHandler(Handler handler)(Code) | | Do nothing since this logger adapter does not support handlers.
|
setFilter | public void setFilter(Filter filter)(Code) | | Do nothing since this logger adapter does not support filters. It is difficult to query
efficiently the filter in this
LoggerAdapter architecture (e.g. we would need to
make sure that
Filter.isLoggable is invoked only once even if a
log call
is cascaded into many other
log calls, and this test must works in multi-threads
environment).
|
setLevel | abstract public void setLevel(Level level)(Code) | | Sets the level for this logger. Subclasses must redirect the call to the external
logging framework, or do nothing if the level can not be changed programmatically.
|
setParent | public void setParent(Logger parent)(Code) | | Do nothing since this logger adapter does not support arbitrary parents.
More specifically, it should not inherits any configuration from a parent
logger using the Java logging framework.
|
setUseParentHandlers | public void setUseParentHandlers(boolean useParentHandlers)(Code) | | Do nothing since this logger never use parent handlers. This is consistent
with
LoggerAdapter.addHandler not allowing to add any handlers, and avoid mixing
loggings from the external framework with Java loggings.
|
throwing | public void throwing(String sourceClass, String sourceMethod, Throwable thrown)(Code) | | Logs a method failure to the
. Compared to the
default
Logger , this implementation bypass the level check in order to let
the backing logging framework do its own check.
|
Methods inherited from java.util.logging.Logger | public synchronized void addHandler(Handler handler) throws SecurityException(Code)(Java Doc) public void config(String msg)(Code)(Java Doc) public void entering(String sourceClass, String sourceMethod)(Code)(Java Doc) public void entering(String sourceClass, String sourceMethod, Object param1)(Code)(Java Doc) public void entering(String sourceClass, String sourceMethod, Object params)(Code)(Java Doc) public void exiting(String sourceClass, String sourceMethod)(Code)(Java Doc) public void exiting(String sourceClass, String sourceMethod, Object result)(Code)(Java Doc) public void fine(String msg)(Code)(Java Doc) public void finer(String msg)(Code)(Java Doc) public void finest(String msg)(Code)(Java Doc) public static synchronized Logger getAnonymousLogger()(Code)(Java Doc) public static synchronized Logger getAnonymousLogger(String resourceBundleName)(Code)(Java Doc) public synchronized Filter getFilter()(Code)(Java Doc) final public static Logger getGlobal()(Code)(Java Doc) public synchronized Handler[] getHandlers()(Code)(Java Doc) public Level getLevel()(Code)(Java Doc) public static synchronized Logger getLogger(String name)(Code)(Java Doc) public static synchronized Logger getLogger(String name, String resourceBundleName)(Code)(Java Doc) public String getName()(Code)(Java Doc) public Logger getParent()(Code)(Java Doc) public ResourceBundle getResourceBundle()(Code)(Java Doc) public String getResourceBundleName()(Code)(Java Doc) public synchronized boolean getUseParentHandlers()(Code)(Java Doc) public void info(String msg)(Code)(Java Doc) public boolean isLoggable(Level level)(Code)(Java Doc) public void log(LogRecord record)(Code)(Java Doc) public void log(Level level, String msg)(Code)(Java Doc) public void log(Level level, String msg, Object param1)(Code)(Java Doc) public void log(Level level, String msg, Object params)(Code)(Java Doc) public void log(Level level, String msg, Throwable thrown)(Code)(Java Doc) public void logp(Level level, String sourceClass, String sourceMethod, String msg)(Code)(Java Doc) public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object param1)(Code)(Java Doc) public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object params)(Code)(Java Doc) public void logp(Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown)(Code)(Java Doc) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg)(Code)(Java Doc) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object param1)(Code)(Java Doc) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object params)(Code)(Java Doc) public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Throwable thrown)(Code)(Java Doc) public synchronized void removeHandler(Handler handler) throws SecurityException(Code)(Java Doc) public synchronized void setFilter(Filter newFilter) throws SecurityException(Code)(Java Doc) public void setLevel(Level newLevel) throws SecurityException(Code)(Java Doc) public void setParent(Logger parent)(Code)(Java Doc) public synchronized void setUseParentHandlers(boolean useParentHandlers)(Code)(Java Doc) public void severe(String msg)(Code)(Java Doc) public void throwing(String sourceClass, String sourceMethod, Throwable thrown)(Code)(Java Doc) public void warning(String msg)(Code)(Java Doc)
|
|
|