fix log levels
This commit is contained in:
22
pom.xml
22
pom.xml
@@ -43,6 +43,28 @@
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</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>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.logging.Logger;
|
||||
|
||||
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 OPENING = 1;
|
||||
@@ -153,12 +153,12 @@ public class Manager extends Emitter {
|
||||
|
||||
if (this._timeout >= 0) {
|
||||
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() {
|
||||
@Override
|
||||
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();
|
||||
socket.close();
|
||||
socket.emit(Engine.EVENT_ERROR, new SocketIOException("timeout"));
|
||||
@@ -244,7 +244,7 @@ public class Manager extends Emitter {
|
||||
}
|
||||
|
||||
/*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));
|
||||
}
|
||||
|
||||
@@ -277,22 +277,22 @@ public class Manager extends Emitter {
|
||||
} else {
|
||||
long delay = this.attempts.get() * this.reconnectionDelay();
|
||||
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;
|
||||
final Future timer = this.reconnectScheduler.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("attempting reconnect");
|
||||
logger.fine("attempting reconnect");
|
||||
self.open(new OpenCallback() {
|
||||
@Override
|
||||
public void call(Exception err) {
|
||||
if (err != null) {
|
||||
logger.info("reconnect attempt error");
|
||||
logger.fine("reconnect attempt error");
|
||||
self.reconnect();
|
||||
self.emit(EVENT_RECONNECT_ERROR, err);
|
||||
} else {
|
||||
logger.info("reconnect success");
|
||||
logger.fine("reconnect success");
|
||||
self.onreconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.logging.Logger;
|
||||
|
||||
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();
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Socket extends Emitter {
|
||||
Packet packet = new Packet(Parser.EVENT, toJsonArray(_args));
|
||||
|
||||
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);
|
||||
packet.id = ids;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class Socket extends Emitter {
|
||||
}
|
||||
|
||||
private void onopen() {
|
||||
logger.info("transport is open - connecting");
|
||||
logger.fine("transport is open - connecting");
|
||||
|
||||
if (!"/".equals(this.nsp)) {
|
||||
this.packet(new Packet(Parser.CONNECT));
|
||||
@@ -150,7 +150,7 @@ public class Socket extends Emitter {
|
||||
}
|
||||
|
||||
private void onclose(String reason) {
|
||||
logger.info(String.format("close (%s)", reason));
|
||||
logger.fine(String.format("close (%s)", reason));
|
||||
this.connected = false;
|
||||
this.disconnected = true;
|
||||
this.emit(EVENT_DISCONNECT, reason);
|
||||
@@ -184,10 +184,10 @@ public class Socket extends Emitter {
|
||||
|
||||
private void onevent(Packet packet) {
|
||||
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) {
|
||||
logger.info("attaching ack callback to event");
|
||||
logger.fine("attaching ack callback to event");
|
||||
args.offerLast(this.ack(packet.id));
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public class Socket extends Emitter {
|
||||
public synchronized void call(Object... args) {
|
||||
if (sent[0]) return;
|
||||
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.id = id;
|
||||
self.packet(packet);
|
||||
@@ -216,7 +216,7 @@ public class Socket extends Emitter {
|
||||
}
|
||||
|
||||
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);
|
||||
fn.call(fromJsonArray(packet.data.getAsJsonArray()).toArray());
|
||||
}
|
||||
@@ -239,13 +239,13 @@ public class Socket extends Emitter {
|
||||
}
|
||||
|
||||
private void ondisconnect() {
|
||||
logger.info(String.format("server disconnect (%s)", this.nsp));
|
||||
logger.fine(String.format("server disconnect (%s)", this.nsp));
|
||||
this.destroy();
|
||||
this.onclose("io server disconnect");
|
||||
}
|
||||
|
||||
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) {
|
||||
sub.destroy();
|
||||
@@ -257,7 +257,7 @@ public class Socket extends Emitter {
|
||||
public Socket close() {
|
||||
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.destroy();
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.logging.Logger;
|
||||
|
||||
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 JsonParser parser = new JsonParser();
|
||||
@@ -56,7 +56,7 @@ public class Parser {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class Parser {
|
||||
return error();
|
||||
}
|
||||
|
||||
logger.info(String.format("decoded %s as %s", str, p));
|
||||
logger.fine(String.format("decoded %s as %s", str, p));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class IOTest {
|
||||
public class ServerConnectionTest {
|
||||
|
||||
final static int TIMEOUT = 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