Repository: logging-log4j2 Updated Branches: refs/heads/master 3efa3fe2d -> 843df122e
Remove extra folder Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/843df122 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/843df122 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/843df122 Branch: refs/heads/master Commit: 843df122e6b00b8b65a9187cbaa32edc97726c8a Parents: 3efa3fe Author: Ralph Goers <[email protected]> Authored: Sun Jun 18 17:22:22 2017 -0700 Committer: Ralph Goers <[email protected]> Committed: Sun Jun 18 17:22:39 2017 -0700 ---------------------------------------------------------------------- .../logging/log4j/util/ClassNamePredicate.java | 45 ------------- .../logging/log4j/util/ClassPredicate.java | 46 ------------- .../apache/logging/log4j/util/StackLocator.java | 39 ----------- .../logging/log4j/util/StackLocatorUtil.java | 70 -------------------- .../log4j/util/StackWalkerStackLocator.java | 63 ------------------ 5 files changed, 263 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/843df122/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassNamePredicate.java ---------------------------------------------------------------------- diff --git a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassNamePredicate.java b/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassNamePredicate.java deleted file mode 100644 index 063e538..0000000 --- a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassNamePredicate.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.logging.log4j.util; - -import java.util.function.Predicate; - -/** - * <em>This class should be considered to be internal.</em> Used to locate the StackFrame that called the named class. - */ -public final class ClassNamePredicate implements Predicate<StackWalker.StackFrame> { - - private final String fqcn; - - public ClassNamePredicate(String fqcn) { - this.fqcn = fqcn; - } - - private boolean next = false; - - @Override - public boolean test(StackWalker.StackFrame f) { - if (fqcn.equals(f.getClassName())) { - next = true; - return false; - } else if (next) { - next = false; - return true; - } - return false; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/843df122/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassPredicate.java ---------------------------------------------------------------------- diff --git a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassPredicate.java b/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassPredicate.java deleted file mode 100644 index 3f8d15a..0000000 --- a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/ClassPredicate.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.logging.log4j.util; - -import java.util.function.Predicate; - -/** - * <em>This class should be considered to be internal.</em> Used to locate the StackFrame that called the named class. - */ - -public final class ClassPredicate implements Predicate<StackWalker.StackFrame> { - - private final Class<?> clazz; - - public ClassPredicate(Class<?> clazz) { - this.clazz = clazz; - } - - private boolean next = false; - - @Override - public boolean test(StackWalker.StackFrame f) { - if (clazz.equals(f.getDeclaringClass())) { - next = true; - return false; - } else if (next) { - next = false; - return true; - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/843df122/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocator.java ---------------------------------------------------------------------- diff --git a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocator.java b/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocator.java deleted file mode 100644 index 3ae15ef..0000000 --- a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.logging.log4j.util; - -import java.util.Stack; - -/** - * Interface for methods used to locate information about the caller. - */ -public interface StackLocator { - - Class<?> getCallerClass(final int depth); - - StackTraceElement getStackTraceElement(final int depth); - - Class<?> getCallerClass(final String fqcn); - - Class<?> getCallerClass(final String fqcn, final String pkg); - - Class<?> getCallerClass(final Class<?> anchor); - - Stack<Class<?>> getCurrentStackTrace(); - - StackTraceElement calcLocation(final String fqcnOfLogger); -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/843df122/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocatorUtil.java ---------------------------------------------------------------------- diff --git a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocatorUtil.java b/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocatorUtil.java deleted file mode 100644 index 326247b..0000000 --- a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackLocatorUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.logging.log4j.util; - -import java.util.Stack; - -/** - * <em>Consider this class private.</em> Provides various methods to determine the caller class. <h3>Background</h3> - */ -public final class StackLocatorUtil { - private static StackLocator stackLocator = null; - - private static final String EMPTY = ""; - - static { - stackLocator = new StackWalkerStackLocator(); - } - - private StackLocatorUtil() { - } - - // TODO: return Object.class instead of null (though it will have a null ClassLoader) - // (MS) I believe this would work without any modifications elsewhere, but I could be wrong - - // migrated from ReflectiveCallerClassUtility - public static Class<?> getCallerClass(final int depth) { - return stackLocator.getCallerClass(depth + 1); - } - - public static StackTraceElement getStackTraceElement(final int depth) { - return stackLocator.getStackTraceElement(depth + 1); - } - // migrated from ClassLoaderContextSelector - public static Class<?> getCallerClass(final String fqcn) { - return getCallerClass(fqcn, EMPTY); - } - - // migrated from Log4jLoggerFactory - public static Class<?> getCallerClass(final String fqcn, final String pkg) { - return stackLocator.getCallerClass(fqcn, pkg); - } - - // added for use in LoggerAdapter implementations mainly - public static Class<?> getCallerClass(final Class<?> anchor) { - return stackLocator.getCallerClass(anchor); - } - - // migrated from ThrowableProxy - public static Stack<Class<?>> getCurrentStackTrace() { - return stackLocator.getCurrentStackTrace(); - } - - public static StackTraceElement calcLocation(final String fqcnOfLogger) { - return stackLocator.calcLocation(fqcnOfLogger); - } -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/843df122/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackWalkerStackLocator.java ---------------------------------------------------------------------- diff --git a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackWalkerStackLocator.java b/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackWalkerStackLocator.java deleted file mode 100644 index dc10fef..0000000 --- a/log4j-api-java9/log4j-api-java9/org/apache/logging/log4j/util/StackWalkerStackLocator.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.logging.log4j.util; - -import java.util.List; -import java.util.Stack; -import java.util.stream.Collectors; - -/** - * <em>Consider this class private.</em> Determines the caller's class. - */ -public class StackWalkerStackLocator implements StackLocator { - - private final static StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); - - private final static StackWalker stackWalker = StackWalker.getInstance(); - - public Class<?> getCallerClass(final String fqcn) { - return getCallerClass(fqcn, ""); - } - - public Class<?> getCallerClass(final String fqcn, final String pkg) { - return walker.walk(s -> s.filter(new ClassNamePredicate(fqcn)).findFirst()).get().getDeclaringClass(); - } - - public Class<?> getCallerClass(final Class<?> anchor) { - return walker.walk(s -> s.filter(new ClassPredicate(anchor)).findFirst()).get().getDeclaringClass(); - } - - public Class<?> getCallerClass(final int depth) { - ; - return walker.walk(s -> s.skip(depth).findFirst()).get().getDeclaringClass(); - } - - public Stack<Class<?>> getCurrentStackTrace() { - Stack<Class<?>> stack = new Stack<Class<?>>(); - List<Class<?>> classes = walker.walk(s -> s.map(f -> f.getDeclaringClass()).collect(Collectors.toList())); - stack.addAll(classes); - return stack; - } - - public StackTraceElement calcLocation(final String fqcnOfLogger) { - return stackWalker.walk(s -> s.filter(new ClassNamePredicate(fqcnOfLogger)).findFirst()).get().toStackTraceElement(); - } - - public StackTraceElement getStackTraceElement(final int depth) { - return stackWalker.walk(s -> s.skip(depth).findFirst()).get().toStackTraceElement(); - } -}
