jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/6] jena git commit: Add Log.warnOnce
Date Wed, 20 May 2015 16:01:20 GMT
Repository: jena
Updated Branches:
  refs/heads/master 8d5f1cb27 -> 8d29aa137


Add Log.warnOnce

Prints a message once(ish) per key.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/78108a83
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/78108a83
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/78108a83

Branch: refs/heads/master
Commit: 78108a83592ff60aaa8bb5f1d5297b49a8117b5e
Parents: 8d5f1cb
Author: Andy Seaborne <andy@apache.org>
Authored: Wed May 20 14:54:19 2015 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Wed May 20 14:54:19 2015 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/jena/atlas/logging/Log.java | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/78108a83/jena-base/src/main/java/org/apache/jena/atlas/logging/Log.java
----------------------------------------------------------------------
diff --git a/jena-base/src/main/java/org/apache/jena/atlas/logging/Log.java b/jena-base/src/main/java/org/apache/jena/atlas/logging/Log.java
index 47783fc..8b8398a 100644
--- a/jena-base/src/main/java/org/apache/jena/atlas/logging/Log.java
+++ b/jena-base/src/main/java/org/apache/jena/atlas/logging/Log.java
@@ -18,6 +18,8 @@
 
 package org.apache.jena.atlas.logging ;
 
+import org.apache.jena.atlas.lib.CacheFactory ;
+import org.apache.jena.atlas.lib.CacheSet ;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
@@ -113,4 +115,13 @@ public class Log {
     static private Logger log(String loggerName) {
         return LoggerFactory.getLogger(loggerName) ;
     }
+
+    private static CacheSet<Object> warningsDone = CacheFactory.createCacheSet(100)
;
+    /** Generate a warning, once(ish) */
+    public static void warnOnce(Class<?> cls, String message, Object key) {
+        if ( ! warningsDone.contains(key) ) {
+            Log.warn(cls, message) ;
+            warningsDone.add(key); 
+        }
+    }
 }


Mime
View raw message