public final class MailLogger
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean |
debug
Produce debug output?
|
private java.util.logging.Logger |
logger
For log messages.
|
private java.io.PrintStream |
out
Stream for debug output.
|
private java.lang.String |
prefix
For debug output.
|
Constructor and Description |
---|
MailLogger(java.lang.Class<?> clazz,
java.lang.String prefix,
boolean debug,
java.io.PrintStream out)
Construct a new MailLogger using the specified class' package
name as the Logger name,
debug prefix (e.g., "DEBUG"), debug flag, and PrintStream.
|
MailLogger(java.lang.Class<?> clazz,
java.lang.String prefix,
Session session)
Deprecated.
|
MailLogger(java.lang.Class<?> clazz,
java.lang.String subname,
java.lang.String prefix,
boolean debug,
java.io.PrintStream out)
Construct a new MailLogger using the specified class' package
name combined with the specified subname as the Logger name,
debug prefix (e.g., "DEBUG"), debug flag, and PrintStream.
|
MailLogger(java.lang.String name,
java.lang.String prefix,
boolean debug,
java.io.PrintStream out)
Construct a new MailLogger using the specified Logger name,
debug prefix (e.g., "DEBUG"), debug flag, and PrintStream.
|
MailLogger(java.lang.String name,
java.lang.String prefix,
Session session)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
config(java.lang.String msg)
Log a message at the CONFIG level.
|
private void |
debugOut(java.lang.String msg)
Common formatting for debug output.
|
void |
fine(java.lang.String msg)
Log a message at the FINE level.
|
void |
finer(java.lang.String msg)
Log a message at the FINER level.
|
void |
finest(java.lang.String msg)
Log a message at the FINEST level.
|
MailLogger |
getLogger(java.lang.Class<?> clazz,
java.lang.String prefix)
Create a MailLogger using the specified class' package
name as the Logger name and the specified prefix.
|
MailLogger |
getLogger(java.lang.String name,
java.lang.String prefix)
Create a MailLogger that uses a Logger with the specified name
and prefix.
|
MailLogger |
getSubLogger(java.lang.String subname,
java.lang.String prefix)
Create a MailLogger that uses a Logger whose name is composed
of this MailLogger's name plus the specified sub-name, separated
by a dot.
|
MailLogger |
getSubLogger(java.lang.String subname,
java.lang.String prefix,
boolean debug)
Create a MailLogger that uses a Logger whose name is composed
of this MailLogger's name plus the specified sub-name, separated
by a dot.
|
private void |
ifDebugOut(java.lang.String msg)
Common code to conditionally log debug statements.
|
private java.lang.StackTraceElement |
inferCaller()
A disadvantage of not being able to use Logger directly in JavaMail
code is that the "source class" information that Logger guesses will
always refer to this class instead of our caller.
|
boolean |
isLoggable(java.util.logging.Level level)
If "debug" is set, or our embedded Logger is loggable at the
given level, return true.
|
private boolean |
isLoggerImplFrame(java.lang.String cname)
Frames to ignore as part of the MailLogger to JUL bridge.
|
void |
log(java.util.logging.Level level,
java.lang.String msg)
Log the message at the specified level.
|
void |
log(java.util.logging.Level level,
java.lang.String msg,
java.lang.Object... params)
Log the message at the specified level.
|
void |
log(java.util.logging.Level level,
java.lang.String msg,
java.lang.Object param1)
Log the message at the specified level.
|
void |
log(java.util.logging.Level level,
java.lang.String msg,
java.lang.Throwable thrown)
Log the message at the specified level.
|
void |
logf(java.util.logging.Level level,
java.lang.String msg,
java.lang.Object... params)
Log the message at the specified level using a format string.
|
private java.lang.String |
packageOf(java.lang.Class<?> clazz)
Return the package name of the class.
|
private final java.util.logging.Logger logger
private final java.lang.String prefix
private final boolean debug
private final java.io.PrintStream out
public MailLogger(java.lang.String name, java.lang.String prefix, boolean debug, java.io.PrintStream out)
name
- the Logger nameprefix
- the prefix for debug output, or null for nonedebug
- if true, write to PrintStreamout
- the PrintStream to write topublic MailLogger(java.lang.Class<?> clazz, java.lang.String prefix, boolean debug, java.io.PrintStream out)
clazz
- the Logger name is the package name of this classprefix
- the prefix for debug output, or null for nonedebug
- if true, write to PrintStreamout
- the PrintStream to write topublic MailLogger(java.lang.Class<?> clazz, java.lang.String subname, java.lang.String prefix, boolean debug, java.io.PrintStream out)
clazz
- the Logger name is the package name of this classsubname
- the Logger name relative to this Logger nameprefix
- the prefix for debug output, or null for nonedebug
- if true, write to PrintStreamout
- the PrintStream to write to@Deprecated public MailLogger(java.lang.String name, java.lang.String prefix, Session session)
name
- the Logger nameprefix
- the prefix for debug output, or null for nonesession
- where to get the debug flag and PrintStream@Deprecated public MailLogger(java.lang.Class<?> clazz, java.lang.String prefix, Session session)
clazz
- the Logger name is the package name of this classprefix
- the prefix for debug output, or null for nonesession
- where to get the debug flag and PrintStreampublic MailLogger getLogger(java.lang.String name, java.lang.String prefix)
name
- the Logger nameprefix
- the prefix for debug output, or null for nonepublic MailLogger getLogger(java.lang.Class<?> clazz, java.lang.String prefix)
clazz
- the Logger name is the package name of this classprefix
- the prefix for debug output, or null for nonepublic MailLogger getSubLogger(java.lang.String subname, java.lang.String prefix)
subname
- the Logger name relative to this Logger nameprefix
- the prefix for debug output, or null for nonepublic MailLogger getSubLogger(java.lang.String subname, java.lang.String prefix, boolean debug)
subname
- the Logger name relative to this Logger nameprefix
- the prefix for debug output, or null for nonedebug
- the debug flag for the sub-loggerpublic void log(java.util.logging.Level level, java.lang.String msg)
level
- the log level.msg
- the message.public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object param1)
level
- the log level.msg
- the message.param1
- the additional parameter.public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Object... params)
level
- the log level.msg
- the message.params
- the message parameters.public void logf(java.util.logging.Level level, java.lang.String msg, java.lang.Object... params)
level
- the log level.msg
- the message format string.params
- the message parameters.public void log(java.util.logging.Level level, java.lang.String msg, java.lang.Throwable thrown)
level
- the log level.msg
- the message.thrown
- the throwable to log.public void config(java.lang.String msg)
msg
- the message.public void fine(java.lang.String msg)
msg
- the message.public void finer(java.lang.String msg)
msg
- the message.public void finest(java.lang.String msg)
msg
- the message.public boolean isLoggable(java.util.logging.Level level)
level
- the log level.private void ifDebugOut(java.lang.String msg)
msg
- the message to log.private void debugOut(java.lang.String msg)
msg
- the message to log.private java.lang.String packageOf(java.lang.Class<?> clazz)
clazz
- the class source.private java.lang.StackTraceElement inferCaller()
private boolean isLoggerImplFrame(java.lang.String cname)
cname
- the class name.