@Override public HandlerConfiguration getHandlerConfiguration(final String handlerName) { synchronized (LOCK) { return delegate.getHandlerConfiguration(handlerName); } }
@Override public HandlerConfiguration getHandlerConfiguration(final String handlerName) { synchronized (LOCK) { return delegate.getHandlerConfiguration(handlerName); } }
@Override public HandlerConfiguration getHandlerConfiguration(final String handlerName) { synchronized (LOCK) { return delegate.getHandlerConfiguration(handlerName); } }
protected abstract void updateModel(HandlerConfiguration configuration, ModelNode model); }
protected abstract void updateModel(HandlerConfiguration configuration, ModelNode model); }
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final LogContextConfiguration logContextConfiguration, final String name, final ModelNode model) throws OperationFailedException { HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); final boolean exists = configuration != null; if (!exists) { LoggingLogger.ROOT_LOGGER.tracef("Adding handler '%s' at '%s'", name, LoggingOperations.getAddress(operation)); configuration = createHandlerConfiguration(context, model, name, logContextConfiguration); } for (AttributeDefinition attribute : attributes) { // CLASS and MODULE should be ignored final boolean skip; if ((attribute.equals(CLASS) || attribute.equals(MODULE)) || attribute.equals(FILTER)) { skip = true; } else { // No need to change values that are equal skip = (exists && equalValue(attribute, context, model, logContextConfiguration, configuration)); } if (!skip) handleProperty(attribute, context, model, logContextConfiguration, configuration); } }
/** * Enables the handler if it was previously disabled. * <p/> * If it was not previously disable, nothing happens. * * @param configuration the log context configuration. * @param handlerName the name of the handler to enable. */ static void enableHandler(final LogContextConfiguration configuration, final String handlerName) { final HandlerConfiguration handlerConfiguration = configuration.getHandlerConfiguration(handlerName); try { handlerConfiguration.setPropertyValueString("enabled", "true"); return; } catch (IllegalArgumentException e) { // do nothing } final Map<String, String> disableHandlers = configuration.getLogContext().getAttachment(CommonAttributes.ROOT_LOGGER_NAME, DISABLED_HANDLERS_KEY); if (disableHandlers != null && disableHandlers.containsKey(handlerName)) { synchronized (HANDLER_LOCK) { final String filter = disableHandlers.get(handlerName); handlerConfiguration.setFilter(filter); disableHandlers.remove(handlerName); } } }
/** * Enables the handler if it was previously disabled. * <p/> * If it was not previously disable, nothing happens. * * @param configuration the log context configuration. * @param handlerName the name of the handler to enable. */ private static void enableHandler(final LogContextConfiguration configuration, final String handlerName) { final HandlerConfiguration handlerConfiguration = configuration.getHandlerConfiguration(handlerName); try { handlerConfiguration.setPropertyValueString("enabled", "true"); return; } catch (IllegalArgumentException e) { // do nothing } final Map<String, String> disableHandlers = configuration.getLogContext().getAttachment(CommonAttributes.ROOT_LOGGER_NAME, DISABLED_HANDLERS_KEY); if (disableHandlers != null && disableHandlers.containsKey(handlerName)) { synchronized (HANDLER_LOCK) { final String filter = disableHandlers.get(handlerName); handlerConfiguration.setFilter(filter); disableHandlers.remove(handlerName); } } }
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } // Uses the operation to get the single handler name being added configuration.removeHandlerName(HANDLER_NAME.resolveModelAttribute(context, operation).asString()); } };
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } // Uses the operation to get the single handler name being added configuration.removeHandlerName(HANDLER_NAME.resolveModelAttribute(context, operation).asString()); } };
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } // Get the handler name, uses the operation to get the single handler name being added final String handlerName = HANDLER_NAME.resolveModelAttribute(context, operation).asString(); if (name.equals(handlerName)) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.cannotAddHandlerToSelf(configuration.getName())); } if (configuration.getHandlerNames().contains(handlerName)) { LoggingLogger.ROOT_LOGGER.tracef("Handler %s is already assigned to handler %s", handlerName, handlerName); } else { configuration.addHandlerName(handlerName); } } };
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } // Get the handler name, uses the operation to get the single handler name being added final String handlerName = HANDLER_NAME.resolveModelAttribute(context, operation).asString(); if (name.equals(handlerName)) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.cannotAddHandlerToSelf(configuration.getName())); } if (configuration.getHandlerNames().contains(handlerName)) { LoggingLogger.ROOT_LOGGER.tracef("Handler %s is already assigned to handler %s", handlerName, handlerName); } else { configuration.addHandlerName(handlerName); } } };
@Override public void configure(InputStream inputStream) throws IOException { this.propertyConfigurator.configure(inputStream); LogContextConfiguration config = this.propertyConfigurator.getLogContextConfiguration(); config.getHandlerConfiguration("CONSOLE").setLevel("ALL"); LevelNode root = InitialLoggerManager.INSTANCE.getRoot(); apply(root, config); config.commit(); }
@Override public void configure(InputStream inputStream) throws IOException { this.propertyConfigurator.configure(inputStream); LogContextConfiguration config = this.propertyConfigurator.getLogContextConfiguration(); config.getHandlerConfiguration("CONSOLE").setLevel("ALL"); LevelNode root = InitialLoggerManager.INSTANCE.getRoot(); apply(root, config); config.commit(); }
@Override public void configure(InputStream inputStream) throws IOException { this.propertyConfigurator.configure(inputStream); LogContextConfiguration config = this.propertyConfigurator.getLogContextConfiguration(); config.getHandlerConfiguration("CONSOLE").setLevel("ALL"); LevelNode root = InitialLoggerManager.INSTANCE.getRoot(); apply(root, config); config.commit(); }
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { configuration = logContextConfiguration.addHandlerConfiguration(null, DelayedHandler.class.getName(), name); } else { if (!(configuration.getInstance() instanceof DelayedHandler)) { throw LoggingLogger.ROOT_LOGGER.invalidType(DelayedHandler.class, configuration.getInstance().getClass()); } } ENABLED.setPropertyValue(context, model, configuration); final ModelNode filter = FILTER_SPEC.resolveModelAttribute(context, model); if (filter.isDefined()) { configuration.setFilter(filter.asString()); } configuration.setLevel(LEVEL.resolvePropertyValue(context, model)); configuration.setFormatterName(NAMED_FORMATTER.resolveModelAttribute(context, model).asString()); }
@Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { configuration = logContextConfiguration.addHandlerConfiguration(null, DelayedHandler.class.getName(), name); } else { if (!(configuration.getInstance() instanceof DelayedHandler)) { throw LoggingLogger.ROOT_LOGGER.invalidType(DelayedHandler.class, configuration.getInstance().getClass()); } } ENABLED.setPropertyValue(context, model, configuration); final ModelNode filter = FILTER_SPEC.resolveModelAttribute(context, model); if (filter.isDefined()) { configuration.setFilter(filter.asString()); } configuration.setLevel(LEVEL.resolvePropertyValue(context, model)); configuration.setFormatterName(NAMED_FORMATTER.resolveModelAttribute(context, model).asString()); }
@SuppressWarnings("deprecation") @Override protected boolean applyUpdate(final OperationContext context, final String attributeName, final String addressName, final ModelNode value, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { // First get the handler configuration. final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(addressName); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(addressName)); } // Handle writing the attribute if (LEVEL.getName().equals(attributeName)) { configuration.setLevel(value.asString()); } else if (NAMED_FORMATTER.getName().equals(attributeName)) { if (value.isDefined()) { configuration.setFormatterName(value.asString()); } else { configuration.setFormatterName(null); } } else if (FILTER_SPEC.getName().equals(attributeName)) { if (value.isDefined()) { configuration.setFilter(value.asString()); } else { configuration.setFilter(null); } } return Logging.requiresReload(getAttributeDefinition(attributeName).getFlags()); }
@Override public final void performRuntime(final OperationContext context, final ModelNode operation, final LogContextConfiguration logContextConfiguration, final String name, final ModelNode model) throws OperationFailedException { final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingMessages.MESSAGES.handlerConfigurationNotFound(name)); } if (attributes != null) { boolean restartRequired = false; boolean reloadRequired = false; for (AttributeDefinition attribute : attributes) { handleProperty(attribute, context, model, logContextConfiguration, configuration); restartRequired = restartRequired || Logging.requiresRestart(attribute.getFlags()); reloadRequired = reloadRequired || Logging.requiresReload(attribute.getFlags()); } if (restartRequired) { context.restartRequired(); } else if (reloadRequired) { context.reloadRequired(); } } performRuntime(context, configuration, name, model); }
@Override public final void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { final String name = context.getCurrentAddressValue(); final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name); if (configuration == null) { throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name)); } final AttributeDefinition[] attributes = getAttributes(); if (attributes != null) { boolean restartRequired = false; boolean reloadRequired = false; for (AttributeDefinition attribute : attributes) { // Only update if the attribute is on the operation if (operation.has(attribute.getName())) { handleProperty(attribute, context, model, logContextConfiguration, configuration); restartRequired = restartRequired || Logging.requiresRestart(attribute.getFlags()); reloadRequired = reloadRequired || Logging.requiresReload(attribute.getFlags()); } } if (restartRequired) { context.restartRequired(); } else if (reloadRequired) { context.reloadRequired(); } } // It's important that properties are written in the correct order, reorder the properties if // needed before the commit. addOrderPropertiesStep(context, propertySorter, configuration); } }