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/29 20:43:51 UTC

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

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

 ##########
 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:
   Is it personal preference or this there another reason for this choice of API over the approach that the SLF4J team landed on? `logger.atDebug().addArgument(() -> t16()).log(msg, "Temperature set to {}. Old temperature was {}.", oldT);`
   
   At first glance, I very much prefer what you have, but I want to give the SLF4J approach some consideration in case there's something obvious I'm missing in why they went this direction.

----------------------------------------------------------------
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