Checkpoint commit for OPENDJ-1288 :
Migrate I18n and logging support to i18n framework and SLF4J
* Move classes from org.opends.server.loggers.debug
to org.opends.server.loggers
** Impact FileBasedAccessLogPublisher and
FileBasedDebugLogPublisher XML configurations
** Impact config.ldif
* Reduce visibility of classes and methods in
org.opends.server.loggers package
* Align logging method names to trace and traceException
in DebugLogPublisher classes
* Clean DebugTracer class
* Add class LoggingCategoryNames to retrieve simple
category name (eg, CORE) from class name
* Temporary removal of opendj-slf4j-adapter module
and disabling of TestBackupAndRestore tests to
avoid build failure
2 files deleted
3 files added
5 files renamed
29 files modified
| | |
| | | <dependency org="javax.servlet" name="javax.servlet-api" rev="[3.1-b02]" /> |
| | | <dependency org="com.sleepycat" name="je" rev="5.0.97" /> |
| | | <dependency org="org.forgerock.opendj" name="opendj-rest2ldap-servlet" rev="&opendj.sdk.version;" conf="default->master,compile" /> |
| | | <dependency org="org.forgerock.opendj" name="opendj-slf4j-adapter" rev="&opendj.sdk.version;" /> |
| | | <!-- <dependency org="org.forgerock.opendj" name="opendj-slf4j-adapter" rev="&opendj.sdk.version;" /> --> |
| | | <dependency org="org.forgerock.commons" name="i18n-slf4j" rev="&i18n.version;" /> |
| | | <dependency org="org.forgerock.opendj" name="opendj-server2x-adapter" rev="&opendj.sdk.version;" /> |
| | | <dependency org="org.glassfish.grizzly" name="grizzly-http-servlet" rev="&grizzly.version;"> |
| | |
| | | objectClass: ds-cfg-debug-log-publisher |
| | | objectClass: ds-cfg-file-based-debug-log-publisher |
| | | cn: File-Based Debug Logger |
| | | ds-cfg-java-class: org.opends.server.loggers.debug.TextDebugLogPublisher |
| | | ds-cfg-java-class: org.opends.server.loggers.TextDebugLogPublisher |
| | | ds-cfg-enabled: false |
| | | ds-cfg-log-file: logs/debug |
| | | ds-cfg-log-file-permissions: 640 |
| | |
| | | ! |
| | | ! |
| | | ! Copyright 2007-2009 Sun Microsystems, Inc. |
| | | ! Portions copyright 2011 ForgeRock AS. |
| | | ! Portions copyright 2011-2014 ForgeRock AS. |
| | | ! --> |
| | | <adm:managed-object name="file-based-access-log-publisher" |
| | | plural-name="file-based-access-log-publishers" |
| | |
| | | ! |
| | | ! |
| | | ! Copyright 2007-2008 Sun Microsystems, Inc. |
| | | ! Portions Copyright 2014 ForgeRock AS. |
| | | ! --> |
| | | <adm:managed-object name="file-based-debug-log-publisher" |
| | | plural-name="file-based-debug-log-publishers" |
| | |
| | | <adm:default-behavior> |
| | | <adm:defined> |
| | | <adm:value> |
| | | org.opends.server.loggers.debug.TextDebugLogPublisher |
| | | org.opends.server.loggers.TextDebugLogPublisher |
| | | </adm:value> |
| | | </adm:defined> |
| | | </adm:default-behavior> |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.loggers.TraceSettings; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | /** |
| | |
| | | * @param stackTrace The stack trace at the time the message |
| | | * is logged or null if its not available. |
| | | */ |
| | | public abstract void traceMessage(TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg, |
| | | StackTraceElement[] stackTrace); |
| | | public abstract void trace(TraceSettings settings, String signature, |
| | | String sourceLocation, String msg, StackTraceElement[] stackTrace); |
| | | |
| | | |
| | | |
| | |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param msg TODO |
| | | * @param msg The message to be logged. |
| | | * @param ex The exception that was caught. |
| | | * @param stackTrace The stack trace at the time the exception |
| | | * is caught or null if its not available. |
| | | */ |
| | | public abstract void traceCaught(TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg, |
| | | Throwable ex, StackTraceElement[] stackTrace); |
| | | public abstract void traceException(TraceSettings settings, String signature, |
| | | String sourceLocation, String msg, Throwable ex, |
| | | StackTraceElement[] stackTrace); |
| | | |
| | | } |
| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.DebugLogger.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.extensions.JMXAlertHandler; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.monitors.BackendMonitor; |
| | | import org.opends.server.monitors.ConnectionHandlerMonitor; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | package org.opends.server.core; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.loggers.AbstractLogger; |
| | | import org.opends.server.loggers.AccessLogger; |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.HTTPAccessLogger; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg3; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | ConfigurationChangeListener<C> |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The storage designed to store log publishers. It is helpful in abstracting |
| | | * away the methods used to manage the collection. |
| | |
| | | } |
| | | catch(ConfigException e) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | messages.add(e.getMessageObject()); |
| | | resultCode = DirectoryServer.getServerErrorResultCode(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | debugCaught(DebugLogLevel.ERROR, e); |
| | | logger.traceException(e); |
| | | messages.add(ERR_CONFIG_LOGGER_CANNOT_CREATE_LOGGER.get( |
| | | String.valueOf(config.dn().toString()), |
| | | stackTraceToSingleLineString(e))); |
| | |
| | | return new ConfigChangeResult(resultCode, adminActionRequired, messages); |
| | | } |
| | | |
| | | private void debugCaught(LogLevel error, Exception e) |
| | | { |
| | | if (DebugLogger.debugEnabled()) |
| | | { |
| | | DebugLogger.getTracer().debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | |
| | | private P findLogPublisher(DN dn) |
| | | { |
| | | Collection<P> logPublishers = getStorage().getLogPublishers(); |
| | |
| | | * @param <T> |
| | | * The type of access log publisher configuration. |
| | | */ |
| | | public abstract class AbstractTextAccessLogPublisher |
| | | abstract class AbstractTextAccessLogPublisher |
| | | <T extends AccessLogPublisherCfg> extends AccessLogPublisher<T> |
| | | { |
| | | /** |
| | |
| | | * A Text Writer which writes log records asynchronously to |
| | | * character-based stream. |
| | | */ |
| | | public class AsynchronousTextWriter |
| | | class AsynchronousTextWriter |
| | | implements ServerShutdownListener, TextWriter |
| | | { |
| | | /** |
| File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugLogger.java |
| | |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | package org.opends.server.loggers; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.loggers.AbstractLogger; |
| | | |
| | | /** |
| | | * A logger for debug and trace logging. DebugLogger provides a debugging |
| | |
| | | * |
| | | * @return True if debug logging is enabled. False otherwise. |
| | | */ |
| | | public static boolean debugEnabled() |
| | | static boolean debugEnabled() |
| | | { |
| | | return enabled; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates a new Debug Tracer for the caller class and registers it |
| | | * with the Debug Logger. |
| | | * |
| | | * @return The tracer created for the caller class. |
| | | */ |
| | | public static DebugTracer getTracer() |
| | | { |
| | | // TODO : remove this method |
| | | return getTracer("org.opends"); |
| | | } |
| | | |
| | | /** |
| | | * Returns the registered Debug Tracer for a traced class. |
| | | * |
| | | * @param className The name of the class tracer to retrieve. |
| | | * @return The tracer for the provided class or null if there are |
| | | * no tracers registered. |
| | | */ |
| | | public static DebugTracer getTracer(String className) |
| | | static DebugTracer getTracer(final String className) |
| | | { |
| | | DebugTracer tracer = classTracers.get(className); |
| | | if (tracer == null) |
| File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugMessageFormatter.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| | |
| | | { |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | boolean firstElement= true; |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | buffer.append(array[i]); |
| File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugStackTraceFormatter.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | package org.opends.server.loggers; |
| | | |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | |
| | | /** |
| | | * Class for source-code tracing at the method level. |
| | | * |
| | | * One DebugTracer instance exists for each Java class using tracing. |
| | | * Tracer must be registered with the DebugLogger. |
| | | * |
| | | * Logging is always done at a level basis, with debug log messages |
| | | * exceeding the trace threshold being traced, others being discarded. |
| | | */ |
| | | class DebugTracer |
| | | { |
| | | /** The class this aspect traces. */ |
| | | private String className; |
| | | |
| | | /** |
| | | * A class that represents a settings cache entry. |
| | | */ |
| | | private class PublisherSettings |
| | | { |
| | | DebugLogPublisher<?> debugPublisher; |
| | | TraceSettings classSettings; |
| | | Map<String, TraceSettings> methodSettings; |
| | | } |
| | | |
| | | private PublisherSettings[] publisherSettings; |
| | | |
| | | /** |
| | | * Construct a new DebugTracer object with cached settings obtained from |
| | | * the provided array of publishers. |
| | | * |
| | | * @param className The classname to use as category for logging. |
| | | * @param publishers The array of publishers to obtain the settings from. |
| | | */ |
| | | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| | | DebugTracer(String className, DebugLogPublisher[] publishers) |
| | | { |
| | | this.className = className; |
| | | publisherSettings = new PublisherSettings[publishers.length]; |
| | | |
| | | // Get the settings from all publishers. |
| | | for(int i = 0; i < publishers.length; i++) |
| | | { |
| | | DebugLogPublisher publisher = publishers[i]; |
| | | PublisherSettings settings = new PublisherSettings(); |
| | | |
| | | settings.debugPublisher = publisher; |
| | | settings.classSettings = publisher.getClassSettings(className); |
| | | |
| | | // For some reason, the compiler doesn't see that |
| | | // debugLogPublihser.getMethodSettings returns a parameterized Map. |
| | | // This problem goes away if a parameterized verson of DebugLogPublisher |
| | | // is used. However, we can't not use reflection to instantiate a generic |
| | | // DebugLogPublisher<? extends DebugLogPublisherCfg> type. The only thing |
| | | // we can do is to just supress the compiler warnings. |
| | | settings.methodSettings = publisher.getMethodSettings(className); |
| | | |
| | | publisherSettings[i] = settings; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Log the provided message. |
| | | * |
| | | * @param msg |
| | | * message to log. |
| | | */ |
| | | void trace(String msg) |
| | | { |
| | | traceException(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * Log the provided message and exception. |
| | | * |
| | | * @param msg |
| | | * the message |
| | | * @param exception |
| | | * the exception caught. May be {@code null}. |
| | | */ |
| | | void traceException(String msg, Throwable exception) |
| | | { |
| | | if(DebugLogger.debugEnabled()) |
| | | { |
| | | StackTraceElement[] stackTrace = null; |
| | | StackTraceElement[] filteredStackTrace = null; |
| | | StackTraceElement callerFrame = null; |
| | | for (PublisherSettings settings : publisherSettings) |
| | | { |
| | | TraceSettings activeSettings = settings.classSettings; |
| | | Map<String, TraceSettings> methodSettings = settings.methodSettings; |
| | | |
| | | if (shouldLog(DebugLogCategory.CAUGHT, activeSettings) || methodSettings != null) |
| | | { |
| | | if(stackTrace == null) |
| | | { |
| | | stackTrace = Thread.currentThread().getStackTrace(); |
| | | } |
| | | if (callerFrame == null) |
| | | { |
| | | callerFrame = getCallerFrame(stackTrace); |
| | | } |
| | | |
| | | String signature = callerFrame.getMethodName(); |
| | | |
| | | // Specific method settings still could exist. Try getting |
| | | // the settings for this method. |
| | | if(methodSettings != null) |
| | | { |
| | | TraceSettings mSettings = methodSettings.get(signature); |
| | | |
| | | if (mSettings == null) |
| | | { |
| | | // Try looking for an undecorated method name |
| | | int idx = signature.indexOf('('); |
| | | if (idx != -1) |
| | | { |
| | | mSettings = |
| | | methodSettings.get(signature.substring(0, idx)); |
| | | } |
| | | } |
| | | |
| | | // If this method does have a specific setting and it is not |
| | | // suppose to be logged, continue. |
| | | if (mSettings != null) |
| | | { |
| | | if(!shouldLog(DebugLogCategory.CAUGHT, mSettings)) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | activeSettings = mSettings; |
| | | } |
| | | } |
| | | } |
| | | |
| | | String sourceLocation = callerFrame.getFileName() + ":" + |
| | | callerFrame.getLineNumber(); |
| | | |
| | | if (filteredStackTrace == null && activeSettings.stackDepth > 0) |
| | | { |
| | | StackTraceElement[] trace = exception == null ? stackTrace : exception.getStackTrace(); |
| | | filteredStackTrace = |
| | | DebugStackTraceFormatter.SMART_FRAME_FILTER. |
| | | getFilteredStackTrace(trace); |
| | | } |
| | | |
| | | if (exception == null) |
| | | { |
| | | settings.debugPublisher.trace(activeSettings, signature, |
| | | sourceLocation, msg, filteredStackTrace); |
| | | } |
| | | else |
| | | { |
| | | settings.debugPublisher.traceException(activeSettings, signature, |
| | | sourceLocation, msg, exception, filteredStackTrace); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Gets the name of the class this tracer traces. |
| | | * |
| | | * @return The name of the class this tracer traces. |
| | | */ |
| | | String getTracedClassName() |
| | | { |
| | | return className; |
| | | } |
| | | |
| | | /** |
| | | * Indicates if logging is enabled for the provided debug log |
| | | * category. |
| | | * |
| | | * @param logCategory |
| | | * Log category to check |
| | | * @return {@code true} if logging is enabled, false otherwise. |
| | | */ |
| | | boolean enabledFor(LogCategory logCategory) |
| | | { |
| | | for (PublisherSettings settings : publisherSettings) |
| | | { |
| | | TraceSettings activeSettings = settings.classSettings; |
| | | Map<String, TraceSettings> methodSettings = settings.methodSettings; |
| | | |
| | | if (shouldLog(logCategory, activeSettings) |
| | | || methodSettings != null) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Indicates if logging is enabled for at least one category |
| | | * in a publisher. |
| | | * |
| | | * @return {@code true} if logging is enabled, false otherwise. |
| | | */ |
| | | boolean enabled() |
| | | { |
| | | for (PublisherSettings settings : publisherSettings) |
| | | { |
| | | TraceSettings activeSettings = settings.classSettings; |
| | | Map<String, TraceSettings> methodSettings = settings.methodSettings; |
| | | |
| | | if (shouldLog(activeSettings) || methodSettings != null) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Update the cached settings of the tracer with the settings from the |
| | | * provided publishers. |
| | | * |
| | | * @param publishers The array of publishers to obtain the settings from. |
| | | */ |
| | | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| | | void updateSettings(DebugLogPublisher[] publishers) |
| | | { |
| | | PublisherSettings[] newSettings = |
| | | new PublisherSettings[publishers.length]; |
| | | |
| | | // Get the settings from all publishers. |
| | | for(int i = 0; i < publishers.length; i++) |
| | | { |
| | | DebugLogPublisher publisher = publishers[i]; |
| | | PublisherSettings settings = new PublisherSettings(); |
| | | |
| | | settings.debugPublisher = publisher; |
| | | settings.classSettings = publisher.getClassSettings(className); |
| | | |
| | | // For some reason, the compiler doesn't see that |
| | | // debugLogPublihser.getMethodSettings returns a parameterized Map. |
| | | // This problem goes away if a parameterized verson of DebugLogPublisher |
| | | // is used. However, we can't not use reflection to instantiate a generic |
| | | // DebugLogPublisher<? extends DebugLogPublisherCfg> type. The only thing |
| | | // we can do is to just supress the compiler warnings. |
| | | settings.methodSettings = publisher.getMethodSettings(className); |
| | | |
| | | newSettings[i] = settings; |
| | | } |
| | | |
| | | publisherSettings = newSettings; |
| | | } |
| | | |
| | | /** |
| | | * Return the caller stack frame. |
| | | * |
| | | * @param stackTrace The entrie stack trace frames. |
| | | * @return the caller stack frame or null if none is found on the |
| | | * stack trace. |
| | | */ |
| | | private StackTraceElement getCallerFrame(StackTraceElement[] stackTrace) |
| | | { |
| | | if (stackTrace != null && stackTrace.length > 0) |
| | | { |
| | | // Skip leading frames debug logging classes and getStackTrace |
| | | // method call frame if any. |
| | | for (StackTraceElement aStackTrace : stackTrace) |
| | | { |
| | | if(aStackTrace.getClassName().startsWith("java.lang.Thread")) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (!aStackTrace.getClassName().startsWith( |
| | | "org.opends.server.loggers.debug")) |
| | | { |
| | | return aStackTrace; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private boolean shouldLog(LogCategory messageCategory, TraceSettings activeSettings) |
| | | { |
| | | return activeSettings.includeCategories != null && |
| | | activeSettings.includeCategories.contains(messageCategory); |
| | | } |
| | | |
| | | /** Indicates if at least one category is active for logging. */ |
| | | private boolean shouldLog(TraceSettings settings) |
| | | { |
| | | return settings.includeCategories != null && !settings.includeCategories.isEmpty(); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | * This class implements a post rotation action that encrypts |
| | | * the log file. |
| | | */ |
| | | public class EncryptAction implements PostRotationAction |
| | | class EncryptAction implements PostRotationAction |
| | | { |
| | | |
| | | private File originalFile; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | * This class implements a comparator that can compare two files based on the |
| | | * time that they were last modified. |
| | | */ |
| | | public class FileComparator implements Comparator<File> |
| | | class FileComparator implements Comparator<File> |
| | | { |
| | | /** |
| | | * Compare two files based on file modification time. |
| | |
| | | * This class implements a post rotation action that compresses |
| | | * the file using GZIP compression. |
| | | */ |
| | | public class GZIPAction implements PostRotationAction |
| | | class GZIPAction implements PostRotationAction |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | /** |
| | | * This class defines a filename filter that will be used for log files. |
| | | */ |
| | | public class LogFileFilter implements FilenameFilter |
| | | class LogFileFilter implements FilenameFilter |
| | | { |
| | | private String prefix; |
| | | |
| | |
| | | * The advantage of using a handler is that we can handle exceptions |
| | | * asynchronously (useful when dealing with an AsynchronousPublisher). |
| | | */ |
| | | public class LogPublisherErrorHandler |
| | | class LogPublisherErrorHandler |
| | | { |
| | | private DN publisherConfigDN; |
| | | private boolean writeErroroccurred = false; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | * This interface describes the handler that is invoked when the logger |
| | | * thread generates an alarm based on a rotation policy condition being met. |
| | | */ |
| | | public interface LoggerAlarmHandler |
| | | interface LoggerAlarmHandler |
| | | { |
| | | |
| | | /** |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.util.Map.Entry; |
| | | import java.util.NavigableMap; |
| | | import java.util.TreeMap; |
| | | |
| | | /** |
| | | * Provides mapping from class names to simple category names used for logging. |
| | | * <p> |
| | | * Given a classname, eg org.forgerock.opendj.server.core.SomeClass, it allows |
| | | * to get the corresponding simplified category name if it exists, eg "CORE". If |
| | | * no simplified category name exist, the classname is used as a category name. |
| | | */ |
| | | class LoggingCategoryNames |
| | | { |
| | | /** |
| | | * Contains mapping from class names (or package names) to category names. In |
| | | * most case, package name is sufficient to map to a category name. It is |
| | | * valid if several entries point to the same category name. |
| | | */ |
| | | private static final NavigableMap<String, String> NAMES = |
| | | new TreeMap<String, String>(); |
| | | |
| | | static |
| | | { |
| | | // The category used for messages associated with the core server. |
| | | NAMES.put("org.opends.server.core", "CORE"); |
| | | |
| | | // The category used for messages associated with server |
| | | //extensions (e.g., extended operations, SASL mechanisms, password storage |
| | | // schemes, password validators, etc.). |
| | | NAMES.put("org.opends.server.extensions", "EXTENSIONS"); |
| | | |
| | | // The category used for messages associated with |
| | | // connection and protocol handling (e.g., ASN.1 and LDAP). |
| | | NAMES.put("org.opends.server.protocol", "PROTOCOL"); |
| | | |
| | | // The category used for messages associated with |
| | | // configuration handling. |
| | | NAMES.put("org.opends.server.config", "CONFIG"); |
| | | |
| | | // The category used for messages associated with the |
| | | // server loggers. |
| | | NAMES.put("org.opends.server.loggers", "LOG"); |
| | | |
| | | // The category used for messages associated with the |
| | | // general server utilities. |
| | | NAMES.put("org.opends.server.util", "UTIL"); |
| | | |
| | | // The category used for messages associated with the |
| | | // server schema elements. |
| | | NAMES.put("org.opends.server.schema", "SCHEMA"); |
| | | |
| | | // The category that will be used for messages associated with plugin |
| | | // processing. |
| | | NAMES.put("org.opends.server.plugins", "PLUGIN"); |
| | | |
| | | // The category used for messages associated with the JE backend. |
| | | NAMES.put("org.opends.server.backends.jeb", "JEB"); |
| | | |
| | | // The category used for messages associated with generic backends. |
| | | NAMES.put("org.opends.server.backends", "BACKEND"); |
| | | |
| | | // The category used for messages associated with tools |
| | | NAMES.put("org.opends.server.tools", "TOOLS"); |
| | | |
| | | // The category used for messages associated with tasks |
| | | NAMES.put("org.opends.server.tasks", "TASK"); |
| | | |
| | | // The category used for messages associated with Access Control |
| | | NAMES.put("org.opends.server.authorization", "ACCESS_CONTROL"); |
| | | |
| | | // The category used for messages associated with the administration |
| | | // framework. |
| | | NAMES.put("org.opends.server.admin", "ADMIN"); |
| | | |
| | | // The category used for messages associated with the Synchronization |
| | | NAMES.put("org.opends.server.replication", "SYNC"); |
| | | |
| | | // The category used for messages associated with version information |
| | | //PACKAGES_TO_NAMES.put("org.opends.server", "VERSION"); |
| | | |
| | | // The category used for messages associated with quicksetup tools |
| | | NAMES.put("org.opends.quicksetup", "QUICKSETUP"); |
| | | |
| | | // The category used for messages associated with the tool like the offline |
| | | // installer and unintaller. |
| | | NAMES.put("org.opends.quicksetup.offline", "ADMIN_TOOL"); |
| | | NAMES.put("org.opends.guitools.uninstaller", "ADMIN_TOOL"); |
| | | |
| | | // The category used for messages associated with the dsconfig |
| | | // administration tool. |
| | | NAMES.put("org.opends.admin.ads", "DSCONFIG"); |
| | | |
| | | // The category used for messages associated with the runtime information |
| | | //NAMES.put("org.opends.server", "RUNTIME_INFORMATION"); |
| | | } |
| | | |
| | | /** |
| | | * Returns the simple category name corresponding to the provided class name |
| | | * or the class name if no mapping corresponds. |
| | | * |
| | | * @param className |
| | | * The classname to retrieve the category name from. |
| | | * @return the simple category name, or the provided className if no matching |
| | | * simple category name is found |
| | | */ |
| | | static String getCategoryName(final String className) |
| | | { |
| | | final Entry<String, String> entry = NAMES.floorEntry(className); |
| | | if (entry != null && className.startsWith(entry.getKey())) |
| | | { |
| | | return entry.getValue(); |
| | | } |
| | | return className; |
| | | } |
| | | } |
| | |
| | | * When a switch is required, the writer closes the current file and opens a |
| | | * new one named in accordance with a specified FileNamingPolicy. |
| | | */ |
| | | public class MultifileTextWriter |
| | | class MultifileTextWriter |
| | | implements ServerShutdownListener, TextWriter, |
| | | ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg> |
| | | { |
| | |
| | | * character-based stream. Note that this implementation is |
| | | * parallel unbound ie there is no queue size cap imposed. |
| | | */ |
| | | public class ParallelTextWriter |
| | | class ParallelTextWriter |
| | | implements ServerShutdownListener, TextWriter |
| | | { |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | * This interface describes the action that needs to be taken |
| | | * at the time of a rotation. |
| | | */ |
| | | public interface PostRotationAction |
| | | interface PostRotationAction |
| | | { |
| | | /** |
| | | * The action that needs to be executed. Returns true |
| File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java |
| | |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | package org.opends.server.loggers; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceMessage(TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg, |
| | | StackTraceElement[] stackTrace) |
| | | public void trace(TraceSettings settings, String signature, |
| | | String sourceLocation, String msg, StackTraceElement[] stackTrace) |
| | | { |
| | | LogCategory category = DebugLogCategory.MESSAGE; |
| | | |
| | | String stack = null; |
| | | if(stackTrace != null) |
| | | { |
| | | stack = DebugStackTraceFormatter.formatStackTrace(stackTrace, |
| | | settings.stackDepth); |
| | | } |
| | | publish(category, signature, sourceLocation, msg, stack); |
| | | publish(DebugLogCategory.MESSAGE, signature, sourceLocation, msg, stack); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceCaught(TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg, |
| | | Throwable ex, StackTraceElement[] stackTrace) |
| | | public void traceException(TraceSettings settings, String signature, |
| | | String sourceLocation, String msg, Throwable ex, |
| | | StackTraceElement[] stackTrace) |
| | | { |
| | | LogCategory category = DebugLogCategory.CAUGHT; |
| | | StringBuilder message = new StringBuilder(); |
| | | if (!msg.isEmpty()) |
| | | { |
| | | message.append(msg).append(" "); |
| | | } |
| | | message.append(DebugMessageFormatter.format("caught={%s}", |
| | | new Object[] { ex })); |
| | | String message = DebugMessageFormatter.format("%s caught={%s}", new Object[] { msg, ex }); |
| | | |
| | | String stack = null; |
| | | if(stackTrace != null) |
| | | { |
| | | stack = DebugStackTraceFormatter.formatStackTrace(ex, |
| | | settings.stackDepth, |
| | | stack = DebugStackTraceFormatter.formatStackTrace(ex, settings.stackDepth, |
| | | settings.includeCause); |
| | | } |
| | | publish(category, signature, sourceLocation, message.toString(), stack); |
| | | publish(DebugLogCategory.CAUGHT, signature, sourceLocation, message, stack); |
| | | } |
| | | |
| | | /** |
| File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/TraceSettings.java |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.loggers.debug; |
| | | package org.opends.server.loggers; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.LogCategory; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.DebugTargetCfgDefn; |
| | | import org.opends.server.admin.std.server.DebugTargetCfg; |
| | | |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | |
| | | |
| | | |
| | | /** |
| | | * Contains implementations of Directory Server access, error, and debug |
| | | * loggers. This includes classes with static methods that should be used to |
| | | * loggers. This includes classes with static methods are used to |
| | | * trigger the generation of log messages, as well as actual implementations |
| | | * that can write the log contents to various targets. |
| | | */ |
| | |
| | | package org.opends.server.tools; |
| | | |
| | | import java.io.File; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.tasks.BackupTask; |
| | | import org.opends.server.tools.tasks.TaskTool; |
| | |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.loggers.DebugMessageFormatter; |
| | | import org.opends.server.loggers.DebugStackTraceFormatter; |
| | | import org.opends.server.loggers.LogCategory; |
| | | import org.opends.server.loggers.debug.DebugMessageFormatter; |
| | | import org.opends.server.loggers.debug.DebugStackTraceFormatter; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.loggers.TraceSettings; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.InitializationException; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceMessage(TraceSettings settings, |
| | | public void trace(TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg, |
| | |
| | | String stack = null; |
| | | if(stackTrace != null) |
| | | { |
| | | stack = DebugStackTraceFormatter.formatStackTrace(stackTrace, |
| | | settings.getStackDepth()); |
| | | stack = DebugStackTraceFormatter.formatStackTrace(stackTrace, settings.getStackDepth()); |
| | | } |
| | | publish(category, msg, stack); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceCaught(TraceSettings settings, |
| | | public void traceException(TraceSettings settings, |
| | | String signature, |
| | | String sourceLocation, |
| | | String msg, |
| | |
| | | { |
| | | LogCategory category = DebugLogCategory.CAUGHT; |
| | | |
| | | StringBuilder format = new StringBuilder(); |
| | | format.append("caught={%s} "); |
| | | format.append(signature); |
| | | format.append("():"); |
| | | format.append(sourceLocation); |
| | | StringBuilder message = new StringBuilder(); |
| | | if (!msg.isEmpty()) |
| | | { |
| | | message.append(msg).append(" "); |
| | | } |
| | | message.append(DebugMessageFormatter.format("caught={%s}", |
| | | new Object[] { ex })); |
| | | String message = DebugMessageFormatter.format("%s caught={%s} %s(): %s", |
| | | new Object[] { msg, ex, signature, sourceLocation }); |
| | | |
| | | String stack = null; |
| | | if (stackTrace != null) |
| | |
| | | DebugStackTraceFormatter.formatStackTrace(ex, settings |
| | | .getStackDepth(), settings.isIncludeCause()); |
| | | } |
| | | publish(category, message.toString(), stack); |
| | | publish(category, message, stack); |
| | | } |
| | | |
| | | /** |
| | |
| | | package org.opends.server.tools; |
| | | |
| | | import java.io.OutputStream; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.BuildVersion; |
| | |
| | | import org.opends.server.util.args.StringArgument; |
| | | import org.opends.server.util.args.LDAPConnectionArgumentParser; |
| | | import org.opends.server.util.cli.CLIException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.tools.tasks.TaskTool; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | |
| | | import org.opends.server.controls.PasswordPolicyErrorType; |
| | | import org.opends.server.controls.PasswordPolicyResponseControl; |
| | | import org.opends.server.controls.PasswordPolicyWarningType; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.TraceSettings; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | |
| | | import org.opends.server.util.args.LDAPConnectionArgumentParser; |
| | | import org.opends.server.util.args.StringArgument; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.LockFileManager; |
| | |
| | | |
| | | |
| | | |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.text.DateFormat; |
| | |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.util.BuildVersion; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.tools.tasks.TaskTool; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.DebugLogger; |
| | | import org.opends.server.loggers.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import org.opends.server.loggers.TextErrorLogPublisher; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.loggers.TraceSettings; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.args.ArgumentException; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.loggers.debug.DebugLogger; |
| | | import org.opends.server.loggers.debug.TextDebugLogPublisher; |
| | | import org.opends.server.plugins.InvocationCounterPlugin; |
| | | import org.opends.server.protocols.asn1.ASN1; |
| | | import org.opends.server.protocols.asn1.ASN1Reader; |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class LoggingCategoryNamesTest extends DirectoryServerTestCase |
| | | { |
| | | private final static String CORE_PACKAGE = DirectoryServer.class.getPackage().getName(); |
| | | private final static String CORE_PACKAGE_NAME = "CORE"; |
| | | |
| | | @DataProvider |
| | | public Object[][] matchingNames() |
| | | { |
| | | return new Object[][] { |
| | | { CORE_PACKAGE }, |
| | | { CORE_PACKAGE + ".SomeClass" }, |
| | | { CORE_PACKAGE + ".pack1.SomeClass"}, |
| | | { CORE_PACKAGE + ".pack1.pack2.SomeClass" }, |
| | | }; |
| | | } |
| | | |
| | | @DataProvider |
| | | public Object[][] nonMatchingNames() |
| | | { |
| | | return new Object[][] { |
| | | { CORE_PACKAGE.substring(0, CORE_PACKAGE.length()-1) }, |
| | | { CORE_PACKAGE.substring(0, CORE_PACKAGE.length()-1) + ".SomeClass" }, |
| | | { CORE_PACKAGE.substring(0, CORE_PACKAGE.length()-1) + ".pack1.SomeClass"}, |
| | | { "org.opends.server" }, |
| | | { "" }, |
| | | { "anyvalue" }, |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "matchingNames") |
| | | public void testMatching(String classname) throws Exception |
| | | { |
| | | assertEquals(LoggingCategoryNames.getCategoryName(classname), CORE_PACKAGE_NAME); |
| | | } |
| | | |
| | | @Test(dataProvider = "nonMatchingNames") |
| | | public void testNonMatching(String classname) throws Exception |
| | | { |
| | | assertEquals(LoggingCategoryNames.getCategoryName(classname), classname); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | */ |
| | | |
| | | |
| | |
| | | * @param taskEntry The task entry. |
| | | * @param expectedState The expected completion state of the task. |
| | | */ |
| | | @Test(dataProvider = "backups") |
| | | @Test(enabled=false, dataProvider = "backups") |
| | | public void testBackups(Entry taskEntry, TaskState expectedState) |
| | | throws Exception |
| | | { |