Skip to content

Commit

Permalink
[WFCORE-6883] Use new logging APIs instead of deprecated ones
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Jul 9, 2024
1 parent 8b35af9 commit 778e667
Show file tree
Hide file tree
Showing 34 changed files with 99 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.wildfly.core.jar.runtime._private;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
Expand All @@ -31,7 +32,7 @@ public interface BootableJarLogger extends BasicLogger {
/**
* Default root logger with category of the package name.
*/
BootableJarLogger ROOT_LOGGER = Logger.getMessageLogger(BootableJarLogger.class, "org.wildfly.jar");
BootableJarLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), BootableJarLogger.class, "org.wildfly.jar");

@LogMessage(level = DEBUG)
@Message(id = 1, value = "Shutting down")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.jboss.as.cli.impl._private;

import java.io.File;
import java.lang.invoke.MethodHandles;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.annotations.MessageLogger;
Expand All @@ -26,7 +27,7 @@ public interface BootScriptInvokerLogger extends BasicLogger {
/**
* Default root logger with category of the package name.
*/
BootScriptInvokerLogger ROOT_LOGGER = Logger.getMessageLogger(BootScriptInvokerLogger.class, "org.jboss.as.cli");
BootScriptInvokerLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), BootScriptInvokerLogger.class, "org.jboss.as.cli");

/**
* Logs an info message to advertise that a script file is being processed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.logging.Logger.Level.WARN;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.net.URL;

Expand All @@ -30,7 +31,7 @@ public interface ControllerClientLogger extends BasicLogger {
/**
* A logger with the default package name.
*/
ControllerClientLogger ROOT_LOGGER = Logger.getMessageLogger(ControllerClientLogger.class, "org.jboss.as.controller.client");
ControllerClientLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ControllerClientLogger.class, "org.jboss.as.controller.client");

/**
* Creates an exception indicating after starting creation of the rollout plan no deployment actions can be added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Path;
Expand Down Expand Up @@ -76,22 +77,22 @@ public interface ControllerLogger extends BasicLogger {
/**
* Default root logger with category of the package name.
*/
ControllerLogger ROOT_LOGGER = Logger.getMessageLogger(ControllerLogger.class, "org.jboss.as.controller");
ControllerLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ControllerLogger.class, "org.jboss.as.controller");

/**
* Logger for management operation messages.
*/
ControllerLogger MGMT_OP_LOGGER = Logger.getMessageLogger(ControllerLogger.class, "org.jboss.as.controller.management-operation");
ControllerLogger MGMT_OP_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ControllerLogger.class, "org.jboss.as.controller.management-operation");

/**
* A logger for logging deprecated resources usage
*/
ControllerLogger DEPRECATED_LOGGER = Logger.getMessageLogger(ControllerLogger.class, "org.jboss.as.controller.management-deprecated");
ControllerLogger DEPRECATED_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ControllerLogger.class, "org.jboss.as.controller.management-deprecated");

/**
* A logger for access control related messages.
*/
ControllerLogger ACCESS_LOGGER = Logger.getMessageLogger(ControllerLogger.class, "org.jboss.as.controller.access-control");
ControllerLogger ACCESS_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ControllerLogger.class, "org.jboss.as.controller.access-control");

/**
* Logs a warning message indicating the address, represented by the {@code address} parameter, could not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;

import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class TransformersLogger {

private TransformersLogger(TransformationTarget target) {
this.target = target;
logger = Logger.getMessageLogger(ControllerLogger.class, "org.jboss.as.controller.transformer." + target.getHostName());
logger = Logger.getMessageLogger(MethodHandles.lookup(), ControllerLogger.class, "org.jboss.as.controller.transformer." + target.getHostName());
}

public static TransformersLogger getLogger(TransformationTarget target){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;

import java.lang.invoke.MethodHandles;
import java.util.Set;

/**
Expand All @@ -28,9 +29,9 @@ public interface CoreManagementLogger extends BasicLogger {
/**
* A logger with a category of the package name.
*/
CoreManagementLogger ROOT_LOGGER = Logger.getMessageLogger(CoreManagementLogger.class, "org.wildfly.extension.core.management");
CoreManagementLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), CoreManagementLogger.class, "org.wildfly.extension.core.management");

CoreManagementLogger UNSUPPORTED_ANNOTATION_LOGGER = Logger.getMessageLogger(CoreManagementLogger.class, "org.wildfly.annotation.unsupported");
CoreManagementLogger UNSUPPORTED_ANNOTATION_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), CoreManagementLogger.class, "org.wildfly.annotation.unsupported");

// @Message(id = 1, value = "The resource %s wasn't working properly and has been removed.")
// String removedOutOfOrderResource(final String address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;

import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import org.jboss.as.repository.ExplodedContentException;
import org.jboss.logging.BasicLogger;
Expand All @@ -28,7 +29,7 @@ public interface DeploymentRepositoryLogger extends BasicLogger {
/**
* A logger with the category of the package name.
*/
DeploymentRepositoryLogger ROOT_LOGGER = Logger.getMessageLogger(DeploymentRepositoryLogger.class, "org.jboss.as.repository");
DeploymentRepositoryLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DeploymentRepositoryLogger.class, "org.jboss.as.repository");

/**
* Logs an informational message indicating the content was added at the location, represented by the {@code path}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.jboss.logging.Logger.Level.WARN;

import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.Set;

import org.jboss.as.controller.OperationFailedException;
Expand All @@ -31,7 +32,7 @@ public interface DeploymentScannerLogger extends BasicLogger {
/**
* A logger with the category of the package name.
*/
DeploymentScannerLogger ROOT_LOGGER = Logger.getMessageLogger(DeploymentScannerLogger.class, "org.jboss.as.server.deployment.scanner");
DeploymentScannerLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DeploymentScannerLogger.class, "org.jboss.as.server.deployment.scanner");

/**
* Logs a warning message indicating the extraneous deployment marker file could not be removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package org.wildfly.extension.discovery;

import java.lang.invoke.MethodHandles;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
Expand All @@ -14,5 +16,5 @@
*/
@MessageLogger(projectCode = "WFDISCEXT", length = 5)
interface Messages extends BasicLogger {
Messages log = Logger.getMessageLogger(Messages.class, "org.wildfly.extension.discovery");
Messages log = Logger.getMessageLogger(MethodHandles.lookup(), Messages.class, "org.wildfly.extension.discovery");
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;

import java.lang.invoke.MethodHandles;
import java.net.InetAddress;

import org.jboss.logging.BasicLogger;
Expand All @@ -25,7 +26,7 @@
@MessageLogger(projectCode = "WFLYDMHTTP", length = 4)

public interface HttpServerLogger extends BasicLogger {
HttpServerLogger ROOT_LOGGER = Logger.getMessageLogger(HttpServerLogger.class, "org.jboss.as.domain.http.api.undertow");
HttpServerLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), HttpServerLogger.class, "org.jboss.as.domain.http.api.undertow");

@LogMessage(level = ERROR)
@Message(id = 1, value = "Unexpected error executing model request")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.jboss.logging.Logger.Level.WARN;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.security.GeneralSecurityException;
import java.util.Collection;
import java.util.Set;
Expand Down Expand Up @@ -44,12 +45,12 @@ public interface DomainManagementLogger extends BasicLogger {
/**
* A logger with a category of the package name.
*/
DomainManagementLogger ROOT_LOGGER = Logger.getMessageLogger(DomainManagementLogger.class, "org.jboss.as.domain.management");
DomainManagementLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainManagementLogger.class, "org.jboss.as.domain.management");

/**
* A logger with category specifically for logging per request security related messages.
*/
DomainManagementLogger SECURITY_LOGGER = Logger.getMessageLogger(DomainManagementLogger.class, "org.jboss.as.domain.management.security");
DomainManagementLogger SECURITY_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainManagementLogger.class, "org.jboss.as.domain.management.security");

/**
* Logs a warning message indicating the user and password were found in the properties file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package org.wildfly.core.elytron.tool.wrapper._private;

import java.lang.invoke.MethodHandles;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Message;
Expand All @@ -21,7 +23,7 @@ public interface ElytronToolWrapperMessages extends BasicLogger {
/**
* A root logger with the category of the package name.
*/
ElytronToolWrapperMessages ROOT_LOGGER = Logger.getMessageLogger(ElytronToolWrapperMessages.class, "org.wildfly.core.elytron.tool.wrapper");
ElytronToolWrapperMessages ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ElytronToolWrapperMessages.class, "org.wildfly.core.elytron.tool.wrapper");

@Message(id = Message.NONE, value = "To make use of the WildFly Elytron Tool, the elytron-tool script should be used instead of wildfly-elytron-tool.jar.\n\n" +
"Run elytron-tool.sh, elytron-tool.bat, or elytron-tool.ps1 with the same arguments that were previously passed when using wildfly-elytron-tool.jar.\n\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.logging.Logger.Level.WARN;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand Down Expand Up @@ -45,7 +46,7 @@ public interface ElytronSubsystemMessages extends BasicLogger {
/**
* A root logger with the category of the package name.
*/
ElytronSubsystemMessages ROOT_LOGGER = Logger.getMessageLogger(ElytronSubsystemMessages.class, "org.wildfly.extension.elytron");
ElytronSubsystemMessages ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), ElytronSubsystemMessages.class, "org.wildfly.extension.elytron");

/**
* {@link OperationFailedException} if the same realm is injected multiple times for a single domain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.wildfly.core.embedded.logging;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;

import org.jboss.logging.BasicLogger;
Expand All @@ -29,7 +30,7 @@ public interface EmbeddedLogger extends BasicLogger {
/**
* A logger with a category of the package name.
*/
EmbeddedLogger ROOT_LOGGER = Logger.getMessageLogger(EmbeddedLogger.class, "org.jboss.as.embedded");
EmbeddedLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), EmbeddedLogger.class, "org.jboss.as.embedded");

// /**
// * Logs a warning message indicating the file handle, represented by the {@code file} parameter, could not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static org.jboss.logging.Logger.Level.WARN;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Collection;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -46,14 +47,14 @@ public interface DomainControllerLogger extends BasicLogger {
* in code specific to the function of the primary Host Controller, e.g. the registration/deregistration
* of secondary Host Contollers.
*/
DomainControllerLogger ROOT_LOGGER = Logger.getMessageLogger(DomainControllerLogger.class, "org.jboss.as.domain.controller");
DomainControllerLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainControllerLogger.class, "org.jboss.as.domain.controller");

/**
* A logger with the category of {@code org.jboss.as.host.controller}.
* <strong>Usage:</strong> Use this in code related to Host Controller functionality, except
* for areas described in the documentation of {@link #ROOT_LOGGER}.
*/
DomainControllerLogger HOST_CONTROLLER_LOGGER = Logger.getMessageLogger(DomainControllerLogger.class, "org.jboss.as.host.controller");
DomainControllerLogger HOST_CONTROLLER_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), DomainControllerLogger.class, "org.jboss.as.host.controller");

@LogMessage(level = Level.WARN)
@Message(id = 1, value = "Ignoring 'include' child of 'socket-binding-group' %s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
Expand Down Expand Up @@ -52,15 +53,15 @@ public interface HostControllerLogger extends BasicLogger {
* <strong>Usage:</strong> Use this in code related to Host Controller functionality, except
* for areas described in the documentation of {@link #DOMAIN_LOGGER}.
*/
HostControllerLogger ROOT_LOGGER = Logger.getMessageLogger(HostControllerLogger.class, "org.jboss.as.host.controller");
HostControllerLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), HostControllerLogger.class, "org.jboss.as.host.controller");

/**
* A logger with a category of {@code org.jboss.as.domain.controller}.
* <strong>Usage:</strong> Use this in OSH code related to the resources persisted in domain.xml, or
* in code specific to the function of the primary Host Controller, e.g. the registration/deregistration
* of secondary Host Contollers.
*/
HostControllerLogger DOMAIN_LOGGER = Logger.getMessageLogger(HostControllerLogger.class, "org.jboss.as.domain.controller");
HostControllerLogger DOMAIN_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), HostControllerLogger.class, "org.jboss.as.domain.controller");

/**
* Logs a warning message indicating the remote domain controller could not connect.
Expand Down Expand Up @@ -1478,4 +1479,4 @@ void noDomainControllerConfigurationProvidedForAdminOnly(String policyAttribute,

@Message(id = Message.NONE, value = "- Minimum feature stability level: %s")
String stabilityInUse(Stability stability);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.wildfly.core.instmgr.logging;

import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
import java.util.Collection;
import java.util.zip.ZipException;
Expand All @@ -24,7 +25,7 @@
@MessageLogger(projectCode = "WFLYIM", length = 4)
public interface InstMgrLogger extends BasicLogger {

InstMgrLogger ROOT_LOGGER = Logger.getMessageLogger(InstMgrLogger.class, "org.wildfly.core.installationmanager");
InstMgrLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), InstMgrLogger.class, "org.wildfly.core.installationmanager");

@Message(id = 1, value = "There is an installation prepared and ready to be applied. The current prepared installation can be discarded by using the 'clean' operation.")
OperationFailedException serverAlreadyPrepared();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;

import java.lang.invoke.MethodHandles;
import java.net.InetSocketAddress;

import org.jboss.as.controller.OperationFailedException;
Expand All @@ -28,7 +29,7 @@ public interface IOLogger extends BasicLogger {
/**
* A root logger with the category of the package name.
*/
IOLogger ROOT_LOGGER = Logger.getMessageLogger(IOLogger.class, "org.wildfly.extension.io");
IOLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), IOLogger.class, "org.wildfly.extension.io");


@LogMessage(level = INFO)
Expand Down
3 changes: 2 additions & 1 deletion jmx/src/main/java/org/jboss/as/jmx/logging/JmxLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.jboss.logging.Logger.Level.ERROR;
import static org.jboss.logging.Logger.Level.WARN;

import java.lang.invoke.MethodHandles;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -44,7 +45,7 @@ public interface JmxLogger extends BasicLogger {
/**
* A logger with the category of the package name.
*/
JmxLogger ROOT_LOGGER = Logger.getMessageLogger(JmxLogger.class, "org.jboss.as.jmx");
JmxLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), JmxLogger.class, "org.jboss.as.jmx");

// /**
// * Creates an exception indicating the inability to shutdown the RMI registry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.jboss.logging.Logger.Level.WARN;

import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.Collection;
import java.util.Set;

Expand Down Expand Up @@ -43,7 +44,7 @@ public interface LoggingLogger extends BasicLogger {
/**
* A root logger with the category of the package name.
*/
LoggingLogger ROOT_LOGGER = Logger.getMessageLogger(LoggingLogger.class, "org.jboss.as.logging");
LoggingLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), LoggingLogger.class, "org.jboss.as.logging");

// id = 1, value = "%s caught exception attempting to revert operation %s at address %s" -- now unused

Expand Down
Loading

0 comments on commit 778e667

Please sign in to comment.