PTLog API - 1.0

jp.ne.dti.lares.foozy.ptlog
Interface LogContext

All Known Implementing Classes:
JCLLogContext, Log4jLogContext, LogAPILogContext, NullLogContext, ThreadLogContext, WriterLogContext

public interface LogContext

Abstraction of logging context information for log service provider.

It is assumed that each instances of this are created for logging subjects(= "who wants to request logging"), and encapsulate management of relation between logging subject and loggability(= whether logging is enabled for it) on each logging type.

In other words, this is as same as Logger of JDK logging API, Log4J or Log of Jakarta Commons Logging.

Major difference between this and them is that this is assumed not to be used directly from logging request code but to be used internally in Log implementation class.

See Also:
Log

Method Summary
 boolean enables(LogType type, java.lang.String method)
          Examine whether specified type logging is enabled for specified method.
 java.lang.String getSubject(boolean embedded)
          Get name of logging request subject.
 void log(LogType type, java.lang.String method, java.lang.String message, java.lang.Throwable throwable)
          Request logging.
 

Method Detail

getSubject

public java.lang.String getSubject(boolean embedded)
Get name of logging request subject.

This method expects to be invoked from constructor of Log.

embedded is true, if returned value is embedded in message (e.g.: "ENTER subject#doSomething()"). Otherwise, returned value is used to identify logging request issuer.

Parameters:
embedded - whether returned value is embedded in message or not.
Returns:
name of logging request subject

enables

public boolean enables(LogType type,
                       java.lang.String method)
Examine whether specified type logging is enabled for specified method.

You should assume that:

invocation cost of this method may be expensive:
calculation result of loggability may be based on not only simple enable/disable configuration, but also complex filterring policy.
result of this method is not strictly exact:
logging request may be ignored even though this method returns "true".

Invocation const and exactness are trade-off between each other, and such trade-off is implementation decision.

This method is provided for Log.enables(jp.ne.dti.lares.foozy.ptlog.LogType).

Parameters:
type - of log record.
method - from which logging request is invoked.
Returns:
true if logging is enabled for such context.

log

public void log(LogType type,
                java.lang.String method,
                java.lang.String message,
                java.lang.Throwable throwable)
Request logging.

This method is provided for Log.log(LogType, String, Throwable).

Parameters:
type - of logging
method - from which logging is requested
message - of logging
throwable - of logging

PTLog API - 1.0