Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOGMGR-351] Remove the deprecated per-deployment logging options. #471

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/main/java/org/jboss/logmanager/LogManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.logging.Filter;

import org.jboss.logmanager.configuration.PropertyLogContextConfigurator;

Expand All @@ -43,24 +42,14 @@
*/
public final class LogManager extends java.util.logging.LogManager {

public static final String PER_THREAD_LOG_FILTER_KEY = "org.jboss.logmanager.useThreadLocalFilter";
static final boolean PER_THREAD_LOG_FILTER;

static {
if (System.getSecurityManager() == null) {
try {
// Ensure the StandardOutputStreams are initialized early to capture the current System.out and System.err.
Class.forName(StandardOutputStreams.class.getName());
} catch (ClassNotFoundException ignore) {
}
PER_THREAD_LOG_FILTER = Boolean.getBoolean(PER_THREAD_LOG_FILTER_KEY);
} else {
PER_THREAD_LOG_FILTER = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return Boolean.getBoolean(PER_THREAD_LOG_FILTER_KEY);
}
});

AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
Expand All @@ -76,10 +65,6 @@ public Object run() {
}
}

private static class LocalFilterHolder {
static final ThreadLocal<Filter> LOCAL_FILTER = new ThreadLocal<>();
}

/**
* Construct a new logmanager instance. Attempts to plug a known memory leak in {@link java.util.logging.Level} as
* well.
Expand Down Expand Up @@ -237,30 +222,4 @@ public boolean addLogger(java.util.logging.Logger logger) {
public Logger getLogger(String name) {
return LogContext.getLogContext().getLogger(name);
}

/**
* Returns the currently set filter for this thread or {@code null} if one has not been set.
* <p>
* If the {@link #PER_THREAD_LOG_FILTER_KEY} is not set to {@code true} then {@code null} will always be returned.
* </p>
*
* @return the filter set for the thread or {@code null} if no level was set
*/
public static Filter getThreadLocalLogFilter() {
return PER_THREAD_LOG_FILTER ? LocalFilterHolder.LOCAL_FILTER.get() : null;
}

/**
* Sets the filter on the thread for all loggers.
* <p>
* This feature only works if the {@link #PER_THREAD_LOG_FILTER} was set to {@code true}
* </p>
*
* @param filter the filter to set for all loggers on this thread
*/
public static void setThreadLocalLogLevel(final Filter filter) {
if (PER_THREAD_LOG_FILTER) {
LocalFilterHolder.LOCAL_FILTER.set(filter);
}
}
}
Loading