use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class LoggerChannelImpl method log.
@Override
public void log(int log_type, String data) {
notifyListeners(log_type, addTimeStamp(data));
if (isEnabled() && !no_output) {
data = "[" + name + "] " + data;
com.biglybt.core.logging.Logger.log(new LogEvent(LOGID, LogTypePluginToCore(log_type), data));
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class LoggerChannelImpl method log.
@Override
public void log(Object[] relatedTo, String str, Throwable error) {
notifyListeners(str.equals("") ? "" : addTimeStamp(str), error);
if (isEnabled() && !no_output) {
str = "[" + name + "] " + str;
com.biglybt.core.logging.Logger.log(new LogEvent(relatedTo, LOGID, str, error));
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class LoggerChannelImpl method log.
@Override
public void log(Object[] relatedTo, int log_type, String data) {
String listenerData;
if (relatedTo != null) {
StringBuilder text = new StringBuilder();
for (int i = 0; i < relatedTo.length; i++) {
Object obj = relatedTo[i];
if (obj == null)
continue;
if (i > 0)
text.append("; ");
if (obj instanceof LogRelation) {
text.append(((LogRelation) obj).getRelationText());
} else {
text.append("RelatedTo[").append(obj.toString()).append("]");
}
}
listenerData = text.toString() + "] " + data;
} else {
listenerData = data;
}
notifyListeners(log_type, addTimeStamp(listenerData));
if (isEnabled() && !no_output) {
data = "[" + name + "] " + data;
com.biglybt.core.logging.Logger.log(new LogEvent(relatedTo, LOGID, LogTypePluginToCore(log_type), data));
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class ClientIDManagerImpl method setupFilter.
private void setupFilter(boolean force) {
synchronized (filter_lock) {
if (!use_filter) {
if (force) {
use_filter = true;
} else {
return;
}
}
if (filter_port != 0) {
return;
}
try {
thread_pool = new ThreadPool("ClientIDManager", 32);
int timeout = connect_timeout + read_timeout;
thread_pool.setExecutionLimit(timeout);
final ServerSocket ss = new ServerSocket(0, 1024, InetAddress.getByName("127.0.0.1"));
filter_port = ss.getLocalPort();
ss.setReuseAddress(true);
new AEThread2("ClientIDManager::filterloop") {
@Override
public void run() {
long failed_accepts = 0;
while (true) {
try {
Socket socket = ss.accept();
failed_accepts = 0;
thread_pool.run(new httpFilter(socket));
} catch (Throwable e) {
failed_accepts++;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "ClientIDManager: listener failed on port " + filter_port, e));
if (failed_accepts > 10) {
// looks like its not going to work...
// some kind of socket problem
Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Network.alert.acceptfail"), new String[] { "" + filter_port, "TCP" });
use_filter = false;
break;
}
}
}
}
}.start();
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "ClientIDManager: listener established on port " + filter_port));
} catch (Throwable e) {
Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Tracker.alert.listenfail"), new String[] { "" + filter_port });
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "ClientIDManager: listener failed on port " + filter_port, e));
use_filter = false;
}
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class Utils method execSWTThreadWithBool.
/**
* Runs code within the SWT thread, waits for code to complete executing,
* (using a semaphore), and then returns a value.
*
* @note USE WITH CAUTION. If the calling function synchronizes, and the
* runnable code ends up synchronizing on the same object, an indefinite
* thread lock or an unexpected timeout may occur (if one of the threads
* is the SWT thread).<p>
* ex - Thread1 calls c.foo(), which synchronized(this).
* - Thread2 is the SWT Thread. Thread2 calls c.foo(), which waits on
* Thread1 to complete.
* - c.foo() from Thread1 calls execSWTThreadWithBoolean(.., swtcode, ..),
* which waits for the SWT Thread to return run the swtcode.
* - Deadlock, or Timoeout which returns a false (and no code ran)
*
* @param ID id for debug
* @param code code to run
* @param millis ms to timeout in
*
* @return returns NULL if code never run
*/
public static Boolean execSWTThreadWithBool(String ID, AERunnableBoolean code, long millis) {
if (code == null) {
Logger.log(new LogEvent(LogIDs.CORE, "code null"));
return null;
}
Boolean[] returnValueObject = { null };
Display display = getDisplay();
AESemaphore sem = null;
if (display == null || display.getThread() != Thread.currentThread()) {
sem = new AESemaphore(ID);
}
try {
code.setupReturn(ID, returnValueObject, sem);
if (!execSWTThread(code)) {
// XXX: throw instead?
return null;
}
} catch (Throwable e) {
if (sem != null) {
sem.release();
}
Debug.out(ID, e);
}
if (sem != null) {
sem.reserve(millis);
}
return returnValueObject[0];
}
Aggregations