|
PTLog API - 1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jp.ne.dti.lares.foozy.ptlog.LogServer jp.ne.dti.lares.foozy.ptlog.EffectiveLogServer jp.ne.dti.lares.foozy.ptlog.ServiceProvider jp.ne.dti.lares.foozy.ptlog.writer.WriterProvider
Log service provider to write log out to specified Writer
.
There are two ways to use this service provider.
One of them is
construction of LogTap
s with this(e.g.: STDOUT
).
Another way is
invocation of
setServer
with this(e.g.: STDOUT
)
on your LogTap
s
(or
setServer
on your LogDirector
).
This allows you to change configuration at runtime.
Specific featuress of this service provider are:
ATTENTION:
This class invokes constructor of base class
with:
DefaultTypeConverter
as converter
java.lang.String
as typeClass
So, TypeConverter
,
which is
registered
to this,
should convert from LogType
to java.lang.String
.
Field Summary | |
static WriterProvider |
STDERR
Convenience to use this class for standard-err without construction. |
static WriterProvider |
STDOUT
Convenience to use this class for standard-out without construction. |
Constructor Summary | |
WriterProvider(java.io.Writer writer)
Constructor. |
|
WriterProvider(java.io.Writer writer,
boolean switchable)
Constructor. |
Method Summary | |
protected boolean |
enables(LogType type,
java.lang.String subject,
java.lang.String method)
Examine loggability of specified type/subject/method. |
LogContext |
getContext(java.lang.Object subject)
Return WriterLogContext . |
boolean |
isSwitchable()
Return whether this instance allows writer switching. |
protected void |
log(LogType type,
java.lang.String subject,
java.lang.String method,
java.lang.String message,
java.lang.Throwable throwable)
Write logging record out to writer. |
void |
setFilter(LogFilter filter)
Set filter to specified one. |
void |
setFormatter(LogFormatter formatter)
Set log formatter to specified one. |
java.io.Writer |
setWriter(java.io.Writer writer)
Use specified writer as new log destination. |
Methods inherited from class jp.ne.dti.lares.foozy.ptlog.ServiceProvider |
addTypeConverter, addTypeConverters, clearTypeConverter, convertType, removeTypeConverter |
Methods inherited from class jp.ne.dti.lares.foozy.ptlog.EffectiveLogServer |
addServee_, getServees, removeServee_ |
Methods inherited from class jp.ne.dti.lares.foozy.ptlog.LogServer |
addServee, fireReconfigure, getSubjectName, removeServee |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final WriterProvider STDOUT
This is constructed by
,
so you can not invoke WriterProvider
(
CloseGuard.STDOUT_WRITER
, false)setWriter(java.io.Writer)
.
Please construct by
if you want to WriterProvider
(
CloseGuard.STDOUT_WRITER
, true)switch
.Writer
public static final WriterProvider STDERR
This is constructed by
WriterProvider
(
CloseGuard.STDERR_WRITER
, false),
so you can not invoke setWriter(java.io.Writer)
.
Please construct by
if you want to WriterProvider
(
CloseGuard.STDERR_WRITER
, true)switch
.Writer
Constructor Detail |
public WriterProvider(java.io.Writer writer, boolean switchable)
null
writer means
CloseGuard.STDOUT_WRITER
.
For resource efficiency,
please use STDOUT
for standard out
(or STDERR
for standard error)
instead of NEW-ing,
except of invocation from derived classes.
ATTENTION: "Closing specified writer" is not responsibility of this class but of user side.
writer
- on which logging information is writen.switchable
- whether setWriter(java.io.Writer)
invocation is allowed.public WriterProvider(java.io.Writer writer)
This is equivalent to
WriterProvider(writer, true)
.
Method Detail |
public final boolean isSwitchable()
setWriter(java.io.Writer)
public final java.io.Writer setWriter(java.io.Writer writer)
This does:
examine switchability
,
and throws runtime exception if it returns false
null
writer means
CloseGuard.STDOUT_WRITER
.
ATTENTION: "Closing old writer" is not responsibility of this class but of caller side.
So, typical invocation code is:
provider.setWriter(newWriter).close();
Please consider to use CloseGuard.StreamWrapper
or
CloseGuard.WriterWrapper
,
if you want not to close some streams/writers
but to close the other ones.
writer
- new log destination
public final void setFilter(LogFilter filter)
null
filter means
AcceptFilter.ALL
.
filter
- of loggingPropertiesFilterConfig
public final void setFormatter(LogFormatter formatter)
null
formatter means
DefaultLogFormatter.INSTANCE
.
formatter
- to format log informationprotected final boolean enables(LogType type, java.lang.String subject, java.lang.String method)
setFilter(jp.ne.dti.lares.foozy.ptlog.writer.LogFilter)
protected final void log(LogType type, java.lang.String subject, java.lang.String method, java.lang.String message, java.lang.Throwable throwable)
This writes logging record out,
if specified logging request is enables
.
Logging record is formatted by
specified formatter
.
public LogContext getContext(java.lang.Object subject)
WriterLogContext
.
getContext
in class LogServer
subject
- of logging request.
|
PTLog API - 1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |