public final class MetaCSPLogging
extends java.lang.Object
implements java.io.Serializable
This class provides basic console logging functionalities for the MetaCSP Framework.
It employs the Logger class, and defines uniform formatter
for the framework.
Each class should have its own specific logger, which is provided by the factory method of
MetaCSPLogging, e.g.,
private Logger logger = MetaCSPLogging.getLogger(this.getClass());
The obtained logger instance can then be used to log messages at different
log-levels (see Level) through the Logger's specific methods, e.g.,
info(String msg), fine(String msg), finer(String msg),
warning(String msg) etc.
To enable logging at a specific level (e.g., from your test class), the static
methods setLevel(Class<?> c, Level l) and setLevel(Level l) are provided.
The former sets the desired level on a specific class (e.g., suppose you want to log at level
Level.FINE only for a MetaConstraintSolver); the latter activates that log
level for all classes which use a Logger provided by the MetaCSPLogging factory
method.
| Modifier and Type | Method and Description |
|---|---|
static java.util.logging.Logger |
getLogger(java.lang.Class<?> c)
Provides a reference to a
Logger which will format log messages according to
the common MetaCSP Framework formatting. |
static java.lang.String |
printDouble(double d,
int precision) |
static void |
setLevel(java.lang.Class<?> c,
java.util.logging.Level l)
Set a desired log level for a specific class.
|
static void |
setLevel(java.util.logging.Level l)
Set a desired log level for all loggers.
|
static void |
setLogDir(java.lang.String dir)
Instruct loggers to log all output to a directory.
|
static void |
showLogs(java.lang.String dir)
Open a LogBrowser to inspect the log files in a given directory.
|
public static void setLogDir(java.lang.String dir)
className.log.dir - The directory to log to.public static void setLevel(java.util.logging.Level l)
l - The desired log level.public static void setLevel(java.lang.Class<?> c,
java.util.logging.Level l)
c - The class to set the log level for.l - The desired log level.public static java.util.logging.Logger getLogger(java.lang.Class<?> c)
Logger which will format log messages according to
the common MetaCSP Framework formatting.c - The class within which the logger should be used.Logger that can be used to log messages in the given class.public static java.lang.String printDouble(double d,
int precision)
public static void showLogs(java.lang.String dir)
dir - The directory containing log files.