You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2020/02/23 18:29:49 UTC
[logging-log4j2] branch master updated: LOG4J2-2789 - Conditionally
perform status logging calculations in PluginRegistry.
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new b09f453 LOG4J2-2789 - Conditionally perform status logging calculations in PluginRegistry.
b09f453 is described below
commit b09f453790225c5fc6c2d875f38c7e4c255ba7d1
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun Feb 23 11:29:26 2020 -0700
LOG4J2-2789 - Conditionally perform status logging calculations in PluginRegistry.
---
.../logging/log4j/plugins/util/PluginRegistry.java | 46 ++++++++++++++--------
src/changes/changes.xml | 3 ++
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/util/PluginRegistry.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/util/PluginRegistry.java
index f18fd1e..344b987 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/util/PluginRegistry.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/util/PluginRegistry.java
@@ -210,11 +210,16 @@ public class PluginRegistry {
}
}
}
- final long endTime = System.nanoTime();
- final DecimalFormat numFormat = new DecimalFormat("#0.000000");
- final double seconds = (endTime - startTime) * 1e-9;
- LOGGER.debug("Took {} seconds to load {} plugins from {}",
- numFormat.format(seconds), pluginCount, classLoader);
+ final int numPlugins = pluginCount;
+ LOGGER.debug(() -> {
+ final long endTime = System.nanoTime();
+ StringBuilder sb = new StringBuilder("Took ");
+ final DecimalFormat numFormat = new DecimalFormat("#0.000000");
+ sb.append(numFormat.format((endTime - startTime) * 1e-9));
+ sb.append(" seconds to load ").append(numPlugins);
+ sb.append(" plugins from ").append(classLoader);
+ return sb.toString();
+ });
}
private Map<String, List<PluginType<?>>> decodeCacheFiles(final ClassLoader loader) {
@@ -251,12 +256,16 @@ public class PluginRegistry {
}
}
}
-
- final long endTime = System.nanoTime();
- final DecimalFormat numFormat = new DecimalFormat("#0.000000");
- final double seconds = (endTime - startTime) * 1e-9;
- LOGGER.debug("Took {} seconds to load {} plugins from {}",
- numFormat.format(seconds), pluginCount, loader);
+ final int numPlugins = pluginCount;
+ LOGGER.debug(() -> {
+ final long endTime = System.nanoTime();
+ StringBuilder sb = new StringBuilder("Took ");
+ final DecimalFormat numFormat = new DecimalFormat("#0.000000");
+ sb.append(numFormat.format((endTime - startTime) * 1e-9));
+ sb.append(" seconds to load ").append(numPlugins);
+ sb.append(" plugins from ").append(loader);
+ return sb.toString();
+ });
return newPluginsByCategory;
}
@@ -318,12 +327,15 @@ public class PluginRegistry {
}
}
}
-
- final long endTime = System.nanoTime();
- final DecimalFormat numFormat = new DecimalFormat("#0.000000");
- final double seconds = (endTime - startTime) * 1e-9;
- LOGGER.debug("Took {} seconds to load {} plugins from package {}",
- numFormat.format(seconds), resolver.getClasses().size(), pkg);
+ LOGGER.debug(() -> {
+ final long endTime = System.nanoTime();
+ StringBuilder sb = new StringBuilder("Took ");
+ final DecimalFormat numFormat = new DecimalFormat("#0.000000");
+ sb.append(numFormat.format((endTime - startTime) * 1e-9));
+ sb.append(" seconds to load ").append(resolver.getClasses().size());
+ sb.append(" plugins from package ").append(pkg);
+ return sb.toString();
+ });
// Note multiple threads could be calling this method concurrently. Both will do the work,
// but only one will be allowed to store the result in the outer map.
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3c9f7ae..e2999d2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -166,6 +166,9 @@
</action>
</release>
<release version="2.13.1" date="2019-MM-DD" description="GA Release 2.13.1">
+ <action issue="LOG4J2-2789" dev="rgeors" type="update" due-to="Marius Volkhart">
+ Conditionally perform status logging calculations in PluginRegistry.
+ </action>
<action issue="LOG4J2-2756" dev="rgoers" type="fix">
Prevent LoggerContext from being garbage collected while being created.
</action>