Package org.deepjava.runtime.mpc555
Class Logger
- java.lang.Object
-
- org.deepjava.runtime.mpc555.Logger
-
public class Logger extends Object
Logger utility to write log messages to aPrintStream
. It is possible to set six different log levels.
-
-
Field Summary
Fields Modifier and Type Field Description static int
config
Indicates a system configuration message.static int
debug
Indicates a debug message.static int
error
Indicates a error message.static int
info
Indicates a information message.static int
none
If the log level is none no message will be logged.static int
warning
Indicates a warning message.
-
Constructor Summary
Constructors Constructor Description Logger(PrintStream stream)
Creates a new Logger object which write log messages to thePrintStream
stream
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getLevel()
Returns the actual level of the logger.void
log(int level, String msg)
Writes a log message to thePrintStream
if the parameterlevel
is greater than the logger level.
With % it is possible to add some arguments to the message.void
log(int level, String msg, int val)
Writes a log message to thePrintStream
if the parameterlevel
is greater than the logger level.
With % it is possible to add some arguments to the message.void
log(int level, String msg, int... values)
Writes a log message to thePrintStream
if the parameterlevel
is greater than the logger level.
With % it is possible to add some arguments to the message.void
setLevel(int level)
Set the log level.
-
-
-
Field Detail
-
none
public static final int none
If the log level is none no message will be logged. Don't use this level to indicate a message by alog
method call, because this level is only used to disable all messages.- See Also:
- Constant Field Values
-
error
public static final int error
Indicates a error message.- See Also:
- Constant Field Values
-
warning
public static final int warning
Indicates a warning message.- See Also:
- Constant Field Values
-
config
public static final int config
Indicates a system configuration message.- See Also:
- Constant Field Values
-
info
public static final int info
Indicates a information message.- See Also:
- Constant Field Values
-
debug
public static final int debug
Indicates a debug message.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Logger
public Logger(PrintStream stream)
Creates a new Logger object which write log messages to thePrintStream
stream
. The standard log level iswarning
.- Parameters:
stream
- The output stream of the logger.
-
-
Method Detail
-
setLevel
public void setLevel(int level)
- Parameters:
level
- the level of the logger.
-
getLevel
public int getLevel()
Returns the actual level of the logger.- Returns:
- the actual level.
-
log
public void log(int level, String msg)
Writes a log message to thePrintStream
if the parameterlevel
is greater than the logger level.
With % it is possible to add some arguments to the message.- %t adds the actual date and time to the message
- %l adds the level description to the message
log(Logger.error,"%l My log message %t",12);
will log following message.
[Erro] My log message 12.11.2009 08:57:13.- Parameters:
level
- the log level of the message.msg
- the message.%d
.
-
log
public void log(int level, String msg, int val)
Writes a log message to thePrintStream
if the parameterlevel
is greater than the logger level.
With % it is possible to add some arguments to the message.- %t adds the actual date and time to the message
- %l adds the level description to the message
- %d adds the parameter
val
to the message
log(Logger.error,"%l My log message with parameter value: %d",12);
will log following message.
[Erro] My log message with parameter value: 12.- Parameters:
level
- the log level of the message.msg
- the message.val
- an integer value which can be added to the message with%d
.
-
log
public void log(int level, String msg, int... values)
Writes a log message to thePrintStream
if the parameterlevel
is greater than the logger level.
With % it is possible to add some arguments to the message.- %t adds the actual date and time to the message
- %l adds the level description to the message
- %d adds the parameters
values
to the message
log(Logger.error,"%l My log message with parameter values: %d, %d, %d,",12,13,14);
will log following message.
[Erro] My log message with parameter value: 12, 13, 14.- Parameters:
level
- the log level of the message.msg
- the message.values
- n integer values which can be added to the message with%d
.
-
-