org.opends.server.loggers.debug
Class TextDebugLogPublisher

java.lang.Object
  extended by org.opends.server.api.DebugLogPublisher<FileBasedDebugLogPublisherCfg>
      extended by org.opends.server.loggers.debug.TextDebugLogPublisher
All Implemented Interfaces:
ConfigurationAddListener<DebugTargetCfg>, ConfigurationChangeListener<FileBasedDebugLogPublisherCfg>, ConfigurationDeleteListener<DebugTargetCfg>

public class TextDebugLogPublisher
extends DebugLogPublisher<FileBasedDebugLogPublisherCfg>
implements ConfigurationChangeListener<FileBasedDebugLogPublisherCfg>, ConfigurationAddListener<DebugTargetCfg>, ConfigurationDeleteListener<DebugTargetCfg>

The debug log publisher implementation that writes debug messages to files on disk. It also maintains the rotation and retention polices of the log files.


Constructor Summary
TextDebugLogPublisher()
           
 
Method Summary
 ConfigChangeResult applyConfigurationAdd(DebugTargetCfg config)
          Adds a new configuration to this add listener.
 ConfigChangeResult applyConfigurationChange(FileBasedDebugLogPublisherCfg config)
          Applies the configuration changes to this change listener.
 ConfigChangeResult applyConfigurationDelete(DebugTargetCfg config)
          Deletes an existing configuration from this delete listener.
 void close()
          Close this publisher.
 DN getDN()
          Gets the DN of the configuration entry for this debug log publisher.
static TextDebugLogPublisher getStartupTextDebugPublisher(TextWriter writer)
          Returns an instance of the text debug log publisher that will print all messages to the provided writer.
 void initializeDebugLogPublisher(FileBasedDebugLogPublisherCfg config)
          Initializes this debug publisher provider based on the information in the provided debug publisher configuration.
 boolean isConfigurationAcceptable(DebugLogPublisherCfg configuration, java.util.List<Message> unacceptableReasons)
          Indicates whether the provided configuration is acceptable for this debug log publisher.
 boolean isConfigurationAddAcceptable(DebugTargetCfg config, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed addition of a new configuration is acceptable to this add listener.
 boolean isConfigurationChangeAcceptable(FileBasedDebugLogPublisherCfg config, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed change to the configuration is acceptable to this change listener.
 boolean isConfigurationDeleteAcceptable(DebugTargetCfg config, java.util.List<Message> unacceptableReasons)
          Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.
 void traceCaught(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.Throwable ex, java.lang.StackTraceElement[] stackTrace)
          Log a caught exception in a method.
 void traceConstructor(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.Object[] args, java.lang.StackTraceElement[] stackTrace)
          Log a constructor entry.
 void traceData(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, byte[] data, java.lang.StackTraceElement[] stackTrace)
          Log raw data in a method.
 void traceJEAccess(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, com.sleepycat.je.OperationStatus status, com.sleepycat.je.Database database, com.sleepycat.je.Transaction txn, com.sleepycat.je.DatabaseEntry key, com.sleepycat.je.DatabaseEntry data, java.lang.StackTraceElement[] stackTrace)
          Log an JE database access in a method.
 void traceMessage(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.String msg, java.lang.StackTraceElement[] stackTrace)
          Log an arbitrary event in a method.
 void traceMethodEntry(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.Object obj, java.lang.Object[] args, java.lang.StackTraceElement[] stackTrace)
          Log a non-static method entry.
 void traceProtocolElement(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, ProtocolElement element, java.lang.StackTraceElement[] stackTrace)
          Log a protocol element in a method.
 void traceReturn(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.Object ret, java.lang.StackTraceElement[] stackTrace)
          Log a method return.
 void traceStaticMethodEntry(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.Object[] args, java.lang.StackTraceElement[] stackTrace)
          Log a static method entry.
 void traceThrown(LogLevel level, TraceSettings settings, java.lang.String signature, java.lang.String sourceLocation, java.lang.Throwable ex, java.lang.StackTraceElement[] stackTrace)
          Log a thrown exception in a method.
 
Methods inherited from class org.opends.server.api.DebugLogPublisher
addTraceSettings, getClassSettings, getMethodSettings, getTraceSettings, removeTraceSettings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextDebugLogPublisher

public TextDebugLogPublisher()
Method Detail

getStartupTextDebugPublisher

public static TextDebugLogPublisher getStartupTextDebugPublisher(TextWriter writer)
Returns an instance of the text debug log publisher that will print all messages to the provided writer. This is used to print the messages to the console when the server starts up. By default, only error level messages are printed. Special debug targets are also parsed from system properties if any are specified.

Parameters:
writer - The text writer where the message will be written to.
Returns:
The instance of the text error log publisher that will print all messages to standard out.

isConfigurationAcceptable

public boolean isConfigurationAcceptable(DebugLogPublisherCfg configuration,
                                         java.util.List<Message> unacceptableReasons)
Indicates whether the provided configuration is acceptable for this debug log publisher. It should be possible to call this method on an uninitialized debug log publisher instance in order to determine whether the debug log publisher would be able to use the provided configuration.

Note that implementations which use a subclass of the provided configuration class will likely need to cast the configuration to the appropriate subclass type.

Overrides:
isConfigurationAcceptable in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
configuration - The debug log publisher configuration for which to make the determination.
unacceptableReasons - A list that may be used to hold the reasons that the provided configuration is not acceptable.
Returns:
true if the provided configuration is acceptable for this debug log publisher, or false if not.

initializeDebugLogPublisher

public void initializeDebugLogPublisher(FileBasedDebugLogPublisherCfg config)
                                 throws ConfigException,
                                        InitializationException
Initializes this debug publisher provider based on the information in the provided debug publisher configuration.

Specified by:
initializeDebugLogPublisher in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
config - The debug publisher configuration that contains the information to use to initialize this debug publisher.
Throws:
ConfigException - If an unrecoverable problem arises in the process of performing the initialization as a result of the server configuration.
InitializationException - If a problem occurs during initialization that is not related to the server configuration.

isConfigurationChangeAcceptable

public boolean isConfigurationChangeAcceptable(FileBasedDebugLogPublisherCfg config,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.

Specified by:
isConfigurationChangeAcceptable in interface ConfigurationChangeListener<FileBasedDebugLogPublisherCfg>
Parameters:
config - The new configuration containing the changes.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed change is acceptable, or false if it is not.

applyConfigurationChange

public ConfigChangeResult applyConfigurationChange(FileBasedDebugLogPublisherCfg config)
Applies the configuration changes to this change listener.

Specified by:
applyConfigurationChange in interface ConfigurationChangeListener<FileBasedDebugLogPublisherCfg>
Parameters:
config - The new configuration containing the changes.
Returns:
Returns information about the result of changing the configuration.

isConfigurationAddAcceptable

public boolean isConfigurationAddAcceptable(DebugTargetCfg config,
                                            java.util.List<Message> unacceptableReasons)
Indicates whether the proposed addition of a new configuration is acceptable to this add listener.

Specified by:
isConfigurationAddAcceptable in interface ConfigurationAddListener<DebugTargetCfg>
Parameters:
config - The configuration that will be added.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed addition is acceptable, or false if it is not.

isConfigurationDeleteAcceptable

public boolean isConfigurationDeleteAcceptable(DebugTargetCfg config,
                                               java.util.List<Message> unacceptableReasons)
Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.

Specified by:
isConfigurationDeleteAcceptable in interface ConfigurationDeleteListener<DebugTargetCfg>
Parameters:
config - The configuration that will be deleted.
unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
Returns:
Returns true if the proposed deletion is acceptable, or false if it is not.

applyConfigurationAdd

public ConfigChangeResult applyConfigurationAdd(DebugTargetCfg config)
Adds a new configuration to this add listener.

Specified by:
applyConfigurationAdd in interface ConfigurationAddListener<DebugTargetCfg>
Parameters:
config - The configuration that will be added.
Returns:
Returns information about the result of adding the configuration.

applyConfigurationDelete

public ConfigChangeResult applyConfigurationDelete(DebugTargetCfg config)
Deletes an existing configuration from this delete listener.

Specified by:
applyConfigurationDelete in interface ConfigurationDeleteListener<DebugTargetCfg>
Parameters:
config - The existing configuration that will be deleted.
Returns:
Returns information about the result of deleting the configuration.

traceConstructor

public void traceConstructor(LogLevel level,
                             TraceSettings settings,
                             java.lang.String signature,
                             java.lang.String sourceLocation,
                             java.lang.Object[] args,
                             java.lang.StackTraceElement[] stackTrace)
Log a constructor entry.

Specified by:
traceConstructor in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The constuctor signature.
sourceLocation - The location of the method in the source.
args - The parameters provided to the constructor.
stackTrace - The stack trace at the time the constructor is executed or null if its not available.

traceMethodEntry

public void traceMethodEntry(LogLevel level,
                             TraceSettings settings,
                             java.lang.String signature,
                             java.lang.String sourceLocation,
                             java.lang.Object obj,
                             java.lang.Object[] args,
                             java.lang.StackTraceElement[] stackTrace)
Log a non-static method entry.

Specified by:
traceMethodEntry in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
obj - The object instance on which the method has been invoked.
args - The parameters provided to the method.
stackTrace - The stack trace at the time the method is executed or null if its not available.

traceStaticMethodEntry

public void traceStaticMethodEntry(LogLevel level,
                                   TraceSettings settings,
                                   java.lang.String signature,
                                   java.lang.String sourceLocation,
                                   java.lang.Object[] args,
                                   java.lang.StackTraceElement[] stackTrace)
Log a static method entry.

Specified by:
traceStaticMethodEntry in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
args - The parameters provided to the method.
stackTrace - The stack trace at the time the method is executed or null if its not available.

traceReturn

public void traceReturn(LogLevel level,
                        TraceSettings settings,
                        java.lang.String signature,
                        java.lang.String sourceLocation,
                        java.lang.Object ret,
                        java.lang.StackTraceElement[] stackTrace)
Log a method return.

Specified by:
traceReturn in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
ret - The return value for the method.
stackTrace - The stack trace at the time the method is returned or null if its not available.

traceThrown

public void traceThrown(LogLevel level,
                        TraceSettings settings,
                        java.lang.String signature,
                        java.lang.String sourceLocation,
                        java.lang.Throwable ex,
                        java.lang.StackTraceElement[] stackTrace)
Log a thrown exception in a method.

Specified by:
traceThrown in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
ex - The exception that was thrown.
stackTrace - The stack trace at the time the exception is thrown or null if its not available.

traceMessage

public void traceMessage(LogLevel level,
                         TraceSettings settings,
                         java.lang.String signature,
                         java.lang.String sourceLocation,
                         java.lang.String msg,
                         java.lang.StackTraceElement[] stackTrace)
Log an arbitrary event in a method.

Specified by:
traceMessage in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
msg - The message to be logged.
stackTrace - The stack trace at the time the message is logged or null if its not available.

traceCaught

public void traceCaught(LogLevel level,
                        TraceSettings settings,
                        java.lang.String signature,
                        java.lang.String sourceLocation,
                        java.lang.Throwable ex,
                        java.lang.StackTraceElement[] stackTrace)
Log a caught exception in a method.

Specified by:
traceCaught in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
ex - The exception that was caught.
stackTrace - The stack trace at the time the exception is caught or null if its not available.

traceJEAccess

public void traceJEAccess(LogLevel level,
                          TraceSettings settings,
                          java.lang.String signature,
                          java.lang.String sourceLocation,
                          com.sleepycat.je.OperationStatus status,
                          com.sleepycat.je.Database database,
                          com.sleepycat.je.Transaction txn,
                          com.sleepycat.je.DatabaseEntry key,
                          com.sleepycat.je.DatabaseEntry data,
                          java.lang.StackTraceElement[] stackTrace)
Log an JE database access in a method.

Specified by:
traceJEAccess in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
status - The status of the JE operation.
database - The database handle.
txn - The transaction handle (may be null).
key - The key to dump.
data - The data to dump.
stackTrace - The stack trace at the time the access occurred or null if its not available.

traceData

public void traceData(LogLevel level,
                      TraceSettings settings,
                      java.lang.String signature,
                      java.lang.String sourceLocation,
                      byte[] data,
                      java.lang.StackTraceElement[] stackTrace)
Log raw data in a method.

Specified by:
traceData in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
data - The data to dump.
stackTrace - The stack trace at the time the data is logged or null if its not available.

traceProtocolElement

public void traceProtocolElement(LogLevel level,
                                 TraceSettings settings,
                                 java.lang.String signature,
                                 java.lang.String sourceLocation,
                                 ProtocolElement element,
                                 java.lang.StackTraceElement[] stackTrace)
Log a protocol element in a method.

Specified by:
traceProtocolElement in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Parameters:
level - The log level for the message.
settings - The current trace settings in effect.
signature - The method signature.
sourceLocation - The location of the method in the source.
element - The protocol element to dump.
stackTrace - The stack trace at the time the protocol element is logged or null if its not available.

close

public void close()
Close this publisher.

Specified by:
close in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>

getDN

public DN getDN()
Gets the DN of the configuration entry for this debug log publisher.

Specified by:
getDN in class DebugLogPublisher<FileBasedDebugLogPublisherCfg>
Returns:
The configuration entry DN.