Use slf4j
This commit is contained in:
parent
bbf7cd9275
commit
124f4942cd
@ -8,9 +8,12 @@ import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InternalClient implements ClientEventsHandler, TelegramClient {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TelegramClient.class);
|
||||
private final ConcurrentHashMap<Long, Handler> handlers = new ConcurrentHashMap<Long, Handler>();
|
||||
private static final java.lang.Object nextClientIdLock = new java.lang.Object();
|
||||
private static int nextClientId = 1;
|
||||
@ -87,7 +90,7 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
||||
handleException(handler.getExceptionHandler(), cause);
|
||||
}
|
||||
} else {
|
||||
System.err.println("Unknown event id " + eventId + ", the event has been dropped!");
|
||||
logger.error("Unknown event id \"{}\", the event has been dropped! {}", eventId, event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +137,7 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
||||
private void createAndRegisterClient() {
|
||||
synchronized (nextClientIdLock) {
|
||||
int nextClientId = InternalClient.nextClientId++;
|
||||
System.out.println("Registering client " + nextClientId);
|
||||
logger.info("Registering client {}", nextClientId);
|
||||
clientManager.registerClient(nextClientId, this);
|
||||
this.clientId = NativeClientAccess.create();
|
||||
if (this.clientId != nextClientId) {
|
||||
|
@ -1,11 +1,15 @@
|
||||
package it.tdlight.common;
|
||||
|
||||
import it.tdlight.jni.TdApi;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InternalClientManager implements AutoCloseable {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(InternalClientManager.class);
|
||||
private static final AtomicReference<InternalClientManager> INSTANCE = new AtomicReference<>(null);
|
||||
|
||||
private final String implementationName;
|
||||
@ -27,15 +31,17 @@ public class InternalClientManager implements AutoCloseable {
|
||||
return INSTANCE.updateAndGet(val -> val == null ? new InternalClientManager(implementationName) : val);
|
||||
}
|
||||
|
||||
private void handleClientEvents(int clientId, boolean isClosed, long[] clientEventIds, Object[] clientEvents) {
|
||||
private void handleClientEvents(int clientId, boolean isClosed, long[] clientEventIds, TdApi.Object[] clientEvents) {
|
||||
ClientEventsHandler handler = registeredClientEventHandlers.get(clientId);
|
||||
|
||||
if (handler != null) {
|
||||
handler.handleEvents(isClosed, clientEventIds, clientEvents);
|
||||
} else {
|
||||
System.err.println("Unknown client id " + clientId + ", " + clientEvents.length + " events have been dropped!");
|
||||
for (Object clientEvent : clientEvents) {
|
||||
System.err.println(clientEvent);
|
||||
logger.error("Unknown client id \"{}\"! {} events have been dropped!", clientId, clientEvents.length);
|
||||
for (int i = 0; i < clientEvents.length; i++) {
|
||||
long id = clientEventIds[i];
|
||||
TdApi.Object event = clientEvents[i];
|
||||
logger.error("The following event, with id \"{}\", has been dropped: {}", id, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,11 @@
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
Loading…
x
Reference in New Issue
Block a user