use of org.python.pydev.shared_core.SharedCorePlugin in project Pydev by fabioz.
the class Log method log.
/**
* @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) {
final String id;
if (SharedCorePlugin.inTestMode()) {
id = "SharedCorePlugin";
} else {
SharedCorePlugin plugin = SharedCorePlugin.getDefault();
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)) {
// Logged in the last 20 seconds, so, just skip it for now
return coreException;
}
}
lastLoggedTime.put(key, currentTimeMillis);
}
try {
if (SharedCorePlugin.inTestMode()) {
if (DEBUG_LEVEL <= errorLevel) {
System.err.println(message);
if (e != null) {
e.printStackTrace();
}
}
} else {
SharedCorePlugin plugin = SharedCorePlugin.getDefault();
plugin.getLog().log(s);
}
} catch (Exception e1) {
// logging should not fail!
}
return coreException;
}
Aggregations