You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2015/08/10 14:01:59 UTC
logging-log4j2 git commit: LOG4J2-599 minor changes to the
documentation for lambda support
Repository: logging-log4j2
Updated Branches:
refs/heads/master 1127b3902 -> 0a7e86125
LOG4J2-599 minor changes to the documentation for lambda support
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0a7e8612
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0a7e8612
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0a7e8612
Branch: refs/heads/master
Commit: 0a7e861254451394c7e761b6fb9d87cded50d734
Parents: 1127b39
Author: rpopma <rp...@apache.org>
Authored: Mon Aug 10 21:01:59 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Mon Aug 10 21:01:59 2015 +0900
----------------------------------------------------------------------
.../src/main/java/org/apache/logging/log4j/Logger.java | 12 ++++--------
src/site/xdoc/manual/api.xml | 8 +++-----
2 files changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0a7e8612/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java b/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
index 82df50b..cf09c10 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/Logger.java
@@ -45,26 +45,22 @@ import org.apache.logging.log4j.util.Supplier;
* {@link org.apache.logging.log4j.spi.AbstractLogger} class rather than implementing this interface directly.
* </p>
*
- * Since 2.4: Extends the {@code Logger} interface with support for lambda expressions.
- * <p>
- * This logger allows client code to lazily log messages without explicitly checking if the requested log level is
+ * Since 2.4, methods have been added to the {@code Logger} interface to support lambda expressions.
+ * The new methods allow client code to lazily log messages without explicitly checking if the requested log level is
* enabled. For example, previously one would write:
*
* <pre>
* // pre-Java 8 style optimization: explicitly check the log level
* // to make sure the expensiveOperation() method is only called if necessary
- * Logger logger = LogManager.getLogger();
* if (logger.isTraceEnabled()) {
* logger.trace("Some long-running operation returned {}", expensiveOperation());
- * }
- * </pre>
+ * }</pre>
* <p>
- * With Java 8 and the {@code Logger} interface, one can achieve the same effect by using a lambda expression:
+ * With Java 8, the same effect can be achieved with a lambda expression:
*
* <pre>
* // Java-8 style optimization: no need to explicitly check the log level:
* // the lambda expression is not evaluated if the TRACE level is not enabled
- * Logger logger = LogManager.getLogger();
* logger.trace("Some long-running operation returned {}", () -> expensiveOperation());
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0a7e8612/src/site/xdoc/manual/api.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/api.xml b/src/site/xdoc/manual/api.xml
index 41c0a7c..9502c80 100644
--- a/src/site/xdoc/manual/api.xml
+++ b/src/site/xdoc/manual/api.xml
@@ -119,22 +119,20 @@ logger.printf(Level.INFO, "Logging in user %1$s with birthday %2$tm %2$te,%2$tY"
<h4>Java 8 lambda support for lazy logging</h4>
<p>
In release 2.4, the <code>Logger</code> interface adds support for lambda expressions.
- The logger allows client code to lazily log messages without explicitly checking if the requested log
+ This allows client code to lazily log messages without explicitly checking if the requested log
level is enabled. For example, previously you would write:
</p>
<pre class="prettyprint linenums">// pre-Java 8 style optimization: explicitly check the log level
// to make sure the expensiveOperation() method is only called if necessary
-Logger logger = LogManager.getLogger();
if (logger.isTraceEnabled()) {
logger.trace("Some long-running operation returned {}", expensiveOperation());
}</pre>
<p>
- With Java 8 and the <code>Logger</code> interface, you can achieve the same effect by using a
- lambda expression. You no longer need to explicitly check the log level:
+ With Java 8 you can achieve the same effect with a lambda expression.
+ You no longer need to explicitly check the log level:
</p>
<pre class="prettyprint linenums">// Java-8 style optimization: no need to explicitly check the log level:
// the lambda expression is not evaluated if the TRACE level is not enabled
-Logger logger = LogManager.getLogger();
logger.trace("Some long-running operation returned {}", () -> expensiveOperation());</pre>
<h4>Logger Names</h4>