You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by GitBox <gi...@apache.org> on 2019/07/30 13:07:49 UTC

[GitHub] [metron] tigerquoll commented on a change in pull request #1473: METRON-2195 rebase onto master

tigerquoll commented on a change in pull request #1473: METRON-2195 rebase onto master
URL: https://github.com/apache/metron/pull/1473#discussion_r308709556
 
 

 ##########
 File path: metron-platform/metron-common/src/main/java/org/apache/metron/common/utils/LazyLogger.java
 ##########
 @@ -0,0 +1,90 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.metron.common.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.Marker;
+
+import java.util.function.Supplier;
+
+/**
+ * Extension of a Logger interface that supports lazy argument evaluation
+ * Useful when some arguments are costly to evaluate, and you only want to incur
+ * that cost if the logging level is actually enabled.
+ */
+public interface LazyLogger extends Logger {
+  void trace(String format, Supplier<Object> arg);
+
+  void trace(String format, Supplier<Object> arg1, Supplier<Object> arg2);
+
+  void trace(String format, Supplier<Object>... arguments);
+
+  void trace(Marker marker, String format, Supplier<Object> arg);
+
+  void trace(Marker marker, String format, Supplier<Object> arg1, Supplier<Object> arg2);
+
+  void trace(Marker marker, String format, Supplier<Object>... arguments);
+
+  void debug(String format, Supplier<Object> arg);
+
+  void debug(String format, Supplier<Object> arg1, Supplier<Object> arg2);
+
+  void debug(String format, Supplier<Object>... arguments);
+
+  void debug(Marker marker, String format, Supplier<Object> arg);
+
+  void debug(Marker marker, String format, Supplier<Object> arg1, Supplier<Object> arg2);
+
+  void debug(Marker marker, String format, Supplier<Object>... arguments);
 
 Review comment:
   For this PR I simply took the SLF4J 1.x Logger Interface API, and extended all methods that took an Object to also have another method that took a Supplier<Object>.  I figured a minimal approach was best, as we would eventually ditch the wrapper once SLF4J fully supported the required functionality.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services