fix log levels
This commit is contained in:
22
pom.xml
22
pom.xml
@@ -43,6 +43,28 @@
|
|||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>2.9</version>
|
||||||
|
<configuration>
|
||||||
|
<show>protected</show>
|
||||||
|
<windowtitle>Socket.IO Client API</windowtitle>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.14.1</version>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>java.util.logging.config.file</name>
|
||||||
|
<value>./src/test/resources/logging.properties</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class Manager extends Emitter {
|
public class Manager extends Emitter {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger("socket.io-client:manager");
|
private static final Logger logger = Logger.getLogger(Manager.class.getName());
|
||||||
|
|
||||||
/*package*/ static final int CLOSED = 0;
|
/*package*/ static final int CLOSED = 0;
|
||||||
/*package*/ static final int OPENING = 1;
|
/*package*/ static final int OPENING = 1;
|
||||||
@@ -153,12 +153,12 @@ public class Manager extends Emitter {
|
|||||||
|
|
||||||
if (this._timeout >= 0) {
|
if (this._timeout >= 0) {
|
||||||
final long timeout = this._timeout;
|
final long timeout = this._timeout;
|
||||||
logger.info(String.format("connection attempt will timeout after %d", timeout));
|
logger.fine(String.format("connection attempt will timeout after %d", timeout));
|
||||||
|
|
||||||
final Future timer = timeoutScheduler.schedule(new Runnable() {
|
final Future timer = timeoutScheduler.schedule(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info(String.format("connect attempt timed out after %d", timeout));
|
logger.fine(String.format("connect attempt timed out after %d", timeout));
|
||||||
openSub.destroy();
|
openSub.destroy();
|
||||||
socket.close();
|
socket.close();
|
||||||
socket.emit(Engine.EVENT_ERROR, new SocketIOException("timeout"));
|
socket.emit(Engine.EVENT_ERROR, new SocketIOException("timeout"));
|
||||||
@@ -244,7 +244,7 @@ public class Manager extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ void packet(Packet packet) {
|
/*package*/ void packet(Packet packet) {
|
||||||
logger.info(String.format("writing packet %s", packet));
|
logger.fine(String.format("writing packet %s", packet));
|
||||||
this.engine.write(Parser.encode(packet));
|
this.engine.write(Parser.encode(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,22 +277,22 @@ public class Manager extends Emitter {
|
|||||||
} else {
|
} else {
|
||||||
long delay = this.attempts.get() * this.reconnectionDelay();
|
long delay = this.attempts.get() * this.reconnectionDelay();
|
||||||
delay = Math.min(delay, this.reconnectionDelayMax());
|
delay = Math.min(delay, this.reconnectionDelayMax());
|
||||||
logger.info(String.format("will wait %dms before reconnect attempt", delay));
|
logger.fine(String.format("will wait %dms before reconnect attempt", delay));
|
||||||
|
|
||||||
this.reconnecting = true;
|
this.reconnecting = true;
|
||||||
final Future timer = this.reconnectScheduler.schedule(new Runnable() {
|
final Future timer = this.reconnectScheduler.schedule(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("attempting reconnect");
|
logger.fine("attempting reconnect");
|
||||||
self.open(new OpenCallback() {
|
self.open(new OpenCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Exception err) {
|
public void call(Exception err) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
logger.info("reconnect attempt error");
|
logger.fine("reconnect attempt error");
|
||||||
self.reconnect();
|
self.reconnect();
|
||||||
self.emit(EVENT_RECONNECT_ERROR, err);
|
self.emit(EVENT_RECONNECT_ERROR, err);
|
||||||
} else {
|
} else {
|
||||||
logger.info("reconnect success");
|
logger.fine("reconnect success");
|
||||||
self.onreconnect();
|
self.onreconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class Socket extends Emitter {
|
public class Socket extends Emitter {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger("socket.io-client:socket");
|
private static final Logger logger = Logger.getLogger(Socket.class.getName());
|
||||||
|
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ public class Socket extends Emitter {
|
|||||||
Packet packet = new Packet(Parser.EVENT, toJsonArray(_args));
|
Packet packet = new Packet(Parser.EVENT, toJsonArray(_args));
|
||||||
|
|
||||||
int ids = this.ids.getAndIncrement();
|
int ids = this.ids.getAndIncrement();
|
||||||
logger.info(String.format("emitting packet with ack id %d", ids));
|
logger.fine(String.format("emitting packet with ack id %d", ids));
|
||||||
this.acks.put(ids, ack);
|
this.acks.put(ids, ack);
|
||||||
packet.id = ids;
|
packet.id = ids;
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onopen() {
|
private void onopen() {
|
||||||
logger.info("transport is open - connecting");
|
logger.fine("transport is open - connecting");
|
||||||
|
|
||||||
if (!"/".equals(this.nsp)) {
|
if (!"/".equals(this.nsp)) {
|
||||||
this.packet(new Packet(Parser.CONNECT));
|
this.packet(new Packet(Parser.CONNECT));
|
||||||
@@ -150,7 +150,7 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onclose(String reason) {
|
private void onclose(String reason) {
|
||||||
logger.info(String.format("close (%s)", reason));
|
logger.fine(String.format("close (%s)", reason));
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.disconnected = true;
|
this.disconnected = true;
|
||||||
this.emit(EVENT_DISCONNECT, reason);
|
this.emit(EVENT_DISCONNECT, reason);
|
||||||
@@ -184,10 +184,10 @@ public class Socket extends Emitter {
|
|||||||
|
|
||||||
private void onevent(Packet packet) {
|
private void onevent(Packet packet) {
|
||||||
LinkedList<Object> args = new LinkedList<Object>(fromJsonArray(packet.data.getAsJsonArray()));
|
LinkedList<Object> args = new LinkedList<Object>(fromJsonArray(packet.data.getAsJsonArray()));
|
||||||
logger.info(String.format("emitting event %s", args));
|
logger.fine(String.format("emitting event %s", args));
|
||||||
|
|
||||||
if (packet.id >= 0) {
|
if (packet.id >= 0) {
|
||||||
logger.info("attaching ack callback to event");
|
logger.fine("attaching ack callback to event");
|
||||||
args.offerLast(this.ack(packet.id));
|
args.offerLast(this.ack(packet.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ public class Socket extends Emitter {
|
|||||||
public synchronized void call(Object... args) {
|
public synchronized void call(Object... args) {
|
||||||
if (sent[0]) return;
|
if (sent[0]) return;
|
||||||
sent[0] = true;
|
sent[0] = true;
|
||||||
logger.info(String.format("sending ack %s", args));
|
logger.fine(String.format("sending ack %s", args));
|
||||||
Packet packet = new Packet(Parser.ACK, gson.toJsonTree(args));
|
Packet packet = new Packet(Parser.ACK, gson.toJsonTree(args));
|
||||||
packet.id = id;
|
packet.id = id;
|
||||||
self.packet(packet);
|
self.packet(packet);
|
||||||
@@ -216,7 +216,7 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onack(Packet packet) {
|
private void onack(Packet packet) {
|
||||||
logger.info(String.format("calling ack %s with %s", packet.id, packet.data));
|
logger.fine(String.format("calling ack %s with %s", packet.id, packet.data));
|
||||||
Ack fn = this.acks.remove(packet.id);
|
Ack fn = this.acks.remove(packet.id);
|
||||||
fn.call(fromJsonArray(packet.data.getAsJsonArray()).toArray());
|
fn.call(fromJsonArray(packet.data.getAsJsonArray()).toArray());
|
||||||
}
|
}
|
||||||
@@ -239,13 +239,13 @@ public class Socket extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ondisconnect() {
|
private void ondisconnect() {
|
||||||
logger.info(String.format("server disconnect (%s)", this.nsp));
|
logger.fine(String.format("server disconnect (%s)", this.nsp));
|
||||||
this.destroy();
|
this.destroy();
|
||||||
this.onclose("io server disconnect");
|
this.onclose("io server disconnect");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroy() {
|
private void destroy() {
|
||||||
logger.info(String.format("destroying socket (%s)", this.nsp));
|
logger.fine(String.format("destroying socket (%s)", this.nsp));
|
||||||
|
|
||||||
for (On.Handle sub : this.subs) {
|
for (On.Handle sub : this.subs) {
|
||||||
sub.destroy();
|
sub.destroy();
|
||||||
@@ -257,7 +257,7 @@ public class Socket extends Emitter {
|
|||||||
public Socket close() {
|
public Socket close() {
|
||||||
if (!this.connected) return this;
|
if (!this.connected) return this;
|
||||||
|
|
||||||
logger.info(String.format("performing disconnect (%s)", this.nsp));
|
logger.fine(String.format("performing disconnect (%s)", this.nsp));
|
||||||
this.packet(new Packet(Parser.DISCONNECT));
|
this.packet(new Packet(Parser.DISCONNECT));
|
||||||
|
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class Parser {
|
public class Parser {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger("socket.io-parser");
|
private static final Logger logger = Logger.getLogger(Parser.class.getName());
|
||||||
|
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
private static final JsonParser parser = new JsonParser();
|
private static final JsonParser parser = new JsonParser();
|
||||||
@@ -56,7 +56,7 @@ public class Parser {
|
|||||||
str.append(gson.toJson(obj.data));
|
str.append(gson.toJson(obj.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(String.format("encoded %s as %s", obj, str));
|
logger.fine(String.format("encoded %s as %s", obj, str));
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ public class Parser {
|
|||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(String.format("decoded %s as %s", str, p));
|
logger.fine(String.format("decoded %s as %s", str, p));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import static org.hamcrest.CoreMatchers.is;
|
|||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class IOTest {
|
public class ServerConnectionTest {
|
||||||
|
|
||||||
final static int TIMEOUT = 3000;
|
final static int TIMEOUT = 3000;
|
||||||
final static int PORT = 3000;
|
final static int PORT = 3000;
|
||||||
8
src/test/resources/logging.properties
Normal file
8
src/test/resources/logging.properties
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
||||||
|
.level = ALL
|
||||||
|
|
||||||
|
java.util.logging.ConsoleHandler.level = FINE
|
||||||
|
|
||||||
|
java.util.logging.FileHandler.level = ALL
|
||||||
|
java.util.logging.FileHandler.pattern = ./target/test.log
|
||||||
|
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
||||||
Reference in New Issue
Block a user