git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8018b97
)
JAL-3163 only log missing message keys once each
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Tue, 27 Nov 2018 16:21:06 +0000
(16:21 +0000)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Tue, 27 Nov 2018 16:21:06 +0000
(16:21 +0000)
src/jalview/util/MessageManager.java
patch
|
blob
|
history
diff --git
a/src/jalview/util/MessageManager.java
b/src/jalview/util/MessageManager.java
index
3dace12
..
2852364
100644
(file)
--- a/
src/jalview/util/MessageManager.java
+++ b/
src/jalview/util/MessageManager.java
@@
-21,11
+21,11
@@
package jalview.util;
import java.text.MessageFormat;
package jalview.util;
import java.text.MessageFormat;
+import java.util.HashSet;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ResourceBundle.Control;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ResourceBundle.Control;
-//import java.util.logging.Level;
-//import java.util.logging.Logger;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.log4j.Logger;
@@
-48,6
+48,8
@@
public class MessageManager
private static Locale loc;
private static Locale loc;
+ private static Set<String> reportedMissing = new HashSet<>();
+
static
{
try
static
{
try
@@
-86,7
+88,8
@@
public class MessageManager
value = rb.getString(key);
} catch (Exception e)
{
value = rb.getString(key);
} catch (Exception e)
{
- log.warn("I18N missing: " + loc + "\t" + key);
+ String msg = "I18N missing: " + loc + "\t" + key;
+ logWarning(key, msg);
}
return value;
}
}
return value;
}
@@
-125,9
+128,25
@@
public class MessageManager
name = rb.getString(smkey);
} catch (Exception x)
{
name = rb.getString(smkey);
} catch (Exception x)
{
- log.info("I18N missing key with root " + keyroot + ": " + loc + "\t"
- + smkey); // was FINEST
+ String msg = "I18N missing key with root " + keyroot + ": " + loc + "\t"
+ + smkey;
+ logWarning(smkey, msg);
}
return name;
}
}
return name;
}
+
+ /**
+ * Logs missing keys (each key once only per run)
+ *
+ * @param key
+ * @param msg
+ */
+ private static void logWarning(String key, String msg)
+ {
+ if (!reportedMissing.contains(key))
+ {
+ reportedMissing.add(key);
+ log.info(msg);
+ }
+ }
}
}