Skip to content

Commit

Permalink
** Initial commit of adding new log manager.
Browse files Browse the repository at this point in the history
Signed-off-by: James R. Perkins <[email protected]>
  • Loading branch information
jamezp committed Jun 30, 2023
1 parent bc958b6 commit fb1ba8f
Show file tree
Hide file tree
Showing 68 changed files with 6,473 additions and 487 deletions.
5 changes: 5 additions & 0 deletions core-feature-pack/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,11 @@
</exclusions>
</dependency>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-logmanager</artifactId>
</dependency>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-management-client-content</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<module name="org.jboss.modules"/>
<module name="org.jboss.stdio"/>
<module name="org.jboss.vfs"/>
<module name="org.wildfly.core.logmanager" services="import"/>
<module name="org.wildfly.common"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<module name="org.jboss.as.jmx" services="import"/>
<module name="org.jboss.as.server" export="true"/>
<module name="org.jboss.vfs" services="import"/>
<module name="org.wildfly.core.logmanager" services="import"/>
<module name="org.wildfly.security.elytron-private" services="import"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<module name="java.desktop"/>
<module name="java.logging"/>
<module name="java.xml"/>
<module name="internal.javax.json.api.ee8"/>
<module name="jakarta.json.api"/>
<module name="io.smallrye.common.constraint"/>
<module name="io.smallrye.common.cpu"/>
<module name="io.smallrye.common.expression"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ JBoss, Home of Professional Open Source.
~
~ Copyright 2023 Red Hat, Inc., and individual contributors
~ as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<module xmlns="urn:jboss:module:1.9" name="org.wildfly.core.logmanager">
<properties>
<property name="jboss.api" value="private"/>
</properties>

<resources>
<artifact name="${org.wildfly.core:wildfly-logmanager}"/>
</resources>

<dependencies>
<module name="java.logging"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.modules"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

<dependencies>
<module name="java.desktop"/>
<module name="java.logging"/>
<module name="org.wildfly.security.elytron-private"/>
<module name="org.wildfly.common"/>
<module name="org.jboss.as.server"/>
Expand All @@ -49,5 +50,6 @@
<module name="org.jboss.modules"/>
<module name="org.jboss.stdio"/>
<module name="org.jboss.threads"/>
<module name="org.wildfly.core.logmanager" services="import"/>
</dependencies>
</module>
11 changes: 11 additions & 0 deletions logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@
</dependency>

<!-- Test dependencies -->
<!-- Required by the log manager for JSON logging -->
<dependency>
<groupId>org.eclipse.parsson</groupId>
<artifactId>parsson</artifactId>
<scope>test</scope>
</dependency>

<!-- Would be brought in transitively by wildfly-controller normally. Required for ParseUtils -->
<dependency>
Expand All @@ -248,6 +254,11 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-logmanager</artifactId>
</dependency>

<!-- JSONP API and IMPL -->
<dependency>
<groupId>org.glassfish</groupId>
Expand Down
10 changes: 10 additions & 0 deletions logging/src/main/java/org/jboss/as/logging/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.registry.AttributeAccess.Flag;
import org.jboss.dmr.ModelNode;
import org.jboss.logmanager.LogContext;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;

/**
* A set of utilities for the logging subsystem.
Expand All @@ -40,6 +42,14 @@ public final class Logging {
private Logging() {
}

// TODO (jrp) we should handle this better
public static LogContext getLogContext(final String profileName) {
if (profileName != null) {
return WildFlyLogContextSelector.getContextSelector().getOrCreateProfile(profileName);
}
return WildFlyLogContextSelector.getContextSelector().getLogContext();
}

/**
* Checks to see within the flags if a restart of any kind is required.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
import org.jboss.as.logging.loggers.LoggerResourceDefinition;
import org.jboss.as.logging.loggers.RootLoggerResourceDefinition;
import org.jboss.as.logging.logging.LoggingLogger;
import org.jboss.as.logging.logmanager.WildFlyLogContextSelector;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;
import org.jboss.as.logging.stdio.LogContextStdioContextSelector;
import org.jboss.dmr.ModelNode;
import org.jboss.logmanager.LogContext;
Expand Down Expand Up @@ -163,9 +163,9 @@ public void initialize(final ExtensionContext context) {
if (embedded) {
// Use the standard WildFlyLogContextSelector if we should wrap the current log context
if (getBooleanProperty(EMBEDDED_PROPERTY, true)) {
contextSelector = WildFlyLogContextSelector.Factory.createEmbedded();
contextSelector = WildFlyLogContextSelector.getEmbeddedContextSelector();
} else {
contextSelector = WildFlyLogContextSelector.Factory.create();
contextSelector = WildFlyLogContextSelector.getContextSelector();
}
} else {

Expand All @@ -186,7 +186,7 @@ public void initialize(final ExtensionContext context) {
throw LoggingLogger.ROOT_LOGGER.extensionNotInitialized();
}
}
contextSelector = WildFlyLogContextSelector.Factory.create();
contextSelector = WildFlyLogContextSelector.getContextSelector();

// Install STDIO context selector
StdioContext.setStdioContextSelector(new LogContextStdioContextSelector(StdioContext.getStdioContext()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static ConfigurationPersistence getOrCreateConfigurationPersistence(fina
final PathAddress address = context.getCurrentAddress();
final ConfigurationPersistence configurationPersistence;
if (LoggingProfileOperations.isLoggingProfileAddress(address)) {
final LogContext logContext = LoggingProfileContextSelector.getInstance().getOrCreate(LoggingProfileOperations.getLoggingProfileName(address));
final LogContext logContext = Logging.getLogContext(LoggingProfileOperations.getLoggingProfileName(address));
configurationPersistence = ConfigurationPersistence.getOrCreateConfigurationPersistence(logContext);
} else {
configurationPersistence = ConfigurationPersistence.getOrCreateConfigurationPersistence();
Expand All @@ -104,7 +104,7 @@ private static ConfigurationPersistence getConfigurationPersistence(final Operat
final PathAddress address = context.getCurrentAddress();
final LogContext logContext;
if (LoggingProfileOperations.isLoggingProfileAddress(address)) {
logContext = LoggingProfileContextSelector.getInstance().get(LoggingProfileOperations.getLoggingProfileName(address));
logContext = Logging.getLogContext(LoggingProfileOperations.getLoggingProfileName(address));
} else {
logContext = LogContext.getLogContext();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.jboss.dmr.ModelNode;
import org.jboss.logmanager.LogContext;
import org.jboss.logmanager.config.LogContextConfiguration;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;

/**
* @author <a href="mailto:[email protected]">James R. Perkins</a>
Expand Down Expand Up @@ -76,8 +77,8 @@ protected void performRuntime(final OperationContext context, final ModelNode op
final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
// Get the logging profile
final String loggingProfile = getLoggingProfileName(address);
final LoggingProfileContextSelector contextSelector = LoggingProfileContextSelector.getInstance();
final LogContext logContext = contextSelector.get(loggingProfile);
final WildFlyLogContextSelector contextSelector = WildFlyLogContextSelector.getContextSelector();
final LogContext logContext = contextSelector.getProfileContext(loggingProfile);
if (logContext != null) {
context.addStep(new OperationStepHandler() {
@Override
Expand Down Expand Up @@ -113,7 +114,7 @@ public void execute(final OperationContext context, final ModelNode operation) {
@Override
public void handleResult(final ResultAction resultAction, final OperationContext context, final ModelNode operation) {
if (resultAction == ResultAction.KEEP) {
contextSelector.remove(loggingProfile);
contextSelector.removeProfileContext(loggingProfile);
} else if (configuration != null) {
context.revertReloadRequired();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import org.jboss.as.controller.transform.description.RejectAttributeChecker;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
import org.jboss.as.logging.logging.LoggingLogger;
import org.jboss.as.logging.logmanager.WildFlyLogContextSelector;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;
import org.jboss.as.server.ServerEnvironment;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import org.jboss.as.logging.loggers.RootLoggerResourceDefinition;
import org.jboss.as.logging.logging.LoggingLogger;
import org.jboss.as.logging.logmanager.ConfigurationPersistence;
import org.jboss.as.logging.logmanager.WildFlyLogContextSelector;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.List;

import org.jboss.as.logging.logging.LoggingLogger;
import org.jboss.as.logging.logmanager.WildFlyLogContextSelector;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
import java.util.Set;

import org.jboss.as.logging.logging.LoggingLogger;
import org.jboss.as.logging.logmanager.WildFlyLogContextSelector;
import org.wildfly.core.logmanager.WildFlyLogContextSelector;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.logmanager.LogContext;
import org.jboss.logmanager.PropertyConfigurator;
import org.jboss.logmanager.config.LogContextConfiguration;
import org.jboss.modules.Module;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
Expand Down Expand Up @@ -217,9 +217,7 @@ private LoggingConfigurationService configure(final ResourceRoot root, final Vir
final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
final PropertyConfigurator propertyConfigurator = new PropertyConfigurator(logContext);
propertyConfigurator.configure(properties);
return new LoggingConfigurationService(propertyConfigurator.getLogContextConfiguration(), resolveRelativePath(root, configFile));
return new LoggingConfigurationService(LogContextConfiguration.create(logContext, properties), resolveRelativePath(root, configFile));
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
}
Expand Down
Loading

0 comments on commit fb1ba8f

Please sign in to comment.