/**
* @param errorLevel IStatus.[OK|INFO|WARNING|ERROR]
* @return CoreException that can be thrown for the given log event
*/
public static CoreException log(int errorLevel, String message, Throwable e) {
SharedCorePlugin plugin = SharedCorePlugin.getDefault();
String id;
if (plugin == null) {
id = "SharedCorePlugin";
} else {
id = plugin.getBundle().getSymbolicName();
}
Status s = new Status(errorLevel, id, errorLevel, message, e);
CoreException coreException = new CoreException(s);
Tuple<Integer, String> key = new Tuple<Integer, String>(errorLevel, message);
synchronized (lastLoggedTime) {
Long lastLoggedMillis = lastLoggedTime.get(key);
long currentTimeMillis = System.currentTimeMillis();
if (lastLoggedMillis != null) {
if (currentTimeMillis < lastLoggedMillis + (20 * 1000)) {
//System.err.println("Skipped report of:"+message);
return coreException; //Logged in the last 20 seconds, so, just skip it for now
}
}
lastLoggedTime.put(key, currentTimeMillis);
}
try {
if (plugin != null) {
plugin.getLog().log(s);
} else {
if (DEBUG_LEVEL <= errorLevel) {
System.err.println(message);
if (e != null) {
e.printStackTrace();