Skip to content

Commit

Permalink
0.5.0 - change logger to slf4j
Browse files Browse the repository at this point in the history
  • Loading branch information
gazer2kanlin committed Apr 2, 2020
1 parent 4cf9de1 commit ce72af9
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 65 deletions.
26 changes: 0 additions & 26 deletions uia.comm/log4j.properties

This file was deleted.

14 changes: 10 additions & 4 deletions uia.comm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.uia.solution</groupId>
<artifactId>uia-comm</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
<packaging>jar</packaging>
<name>uia-comm</name>
<url>https://github.com/uia4j/uia-comm</url>
Expand All @@ -20,9 +20,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.rxtx</groupId>
Expand All @@ -34,6 +35,11 @@
<artifactId>uia-utils</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>
<repositories>
<repository>
Expand Down
5 changes: 3 additions & 2 deletions uia.comm/src/main/java/uia/comm/DatagramClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import java.nio.channels.DatagramChannel;
import java.util.HashMap;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.comm.protocol.Protocol;
import uia.comm.protocol.ProtocolEventArgs;
Expand All @@ -39,7 +40,7 @@
*/
public class DatagramClient implements ProtocolEventHandler<DatagramDataController>, CommClient<DatagramDataController> {

private final static Logger logger = Logger.getLogger(DatagramClient.class);
private final static Logger logger = LoggerFactory.getLogger(DatagramClient.class);

private final Protocol<DatagramDataController> protocol;

Expand Down
11 changes: 6 additions & 5 deletions uia.comm/src/main/java/uia/comm/DatagramDataController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import java.util.Arrays;
import java.util.Iterator;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.comm.protocol.ProtocolMonitor;
import uia.utils.ByteUtils;
Expand All @@ -39,7 +40,7 @@
*/
public class DatagramDataController implements DataController {

private final static Logger logger = Logger.getLogger(DatagramDataController.class);
private final static Logger logger = LoggerFactory.getLogger(DatagramDataController.class);

private final ProtocolMonitor<DatagramDataController> monitor;

Expand Down Expand Up @@ -107,7 +108,7 @@ public synchronized boolean send(byte[] data, int times) {
return true;
}
else {
logger.fatal(String.format("%s> write count error!!", this.name));
logger.error(String.format("%s> write count error!!", this.name));
}
}
catch (Exception ex) {
Expand Down Expand Up @@ -203,7 +204,7 @@ synchronized boolean receive() throws IOException {
value = Arrays.copyOf(value, len);
for (byte b : value) {
if (this.monitor.getDataLength() > this.maxCache) {
logger.fatal(this.name + "> out of maxCchte:" + this.maxCache);
logger.error(this.name + "> out of maxCchte:" + this.maxCache);
this.monitor.reset();
}
this.monitor.read(b);
Expand Down Expand Up @@ -243,7 +244,7 @@ private void running() {
receive();
}
catch (Exception e) {
logger.fatal(dgChannel, e);
logger.error(dgChannel.toString() + " failed", e);
break;
}
}
Expand Down
5 changes: 3 additions & 2 deletions uia.comm/src/main/java/uia/comm/MessageCallOutConcurrent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import java.util.concurrent.Callable;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
Expand All @@ -29,7 +30,7 @@
*/
class MessageCallOutConcurrent implements MessageCallOut, Callable<byte[]> {

private final static Logger logger = Logger.getLogger(MessageCallOutConcurrent.class);
private final static Logger logger = LoggerFactory.getLogger(MessageCallOutConcurrent.class);

private final String name;

Expand Down
5 changes: 3 additions & 2 deletions uia.comm/src/main/java/uia/comm/RS232.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.comm.protocol.Protocol;
import uia.comm.protocol.ProtocolEventArgs;
Expand All @@ -50,7 +51,7 @@
*/
public class RS232 implements ProtocolEventHandler<RS232>, CommClient<RS232> {

private final static Logger logger = Logger.getLogger(RS232.class);
private final static Logger logger = LoggerFactory.getLogger(RS232.class);

private String aliasName;

Expand Down
5 changes: 3 additions & 2 deletions uia.comm/src/main/java/uia/comm/SocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.comm.protocol.Protocol;
import uia.comm.protocol.ProtocolEventArgs;
Expand All @@ -50,7 +51,7 @@
*/
public class SocketClient implements ProtocolEventHandler<SocketDataController>, CommClient<SocketDataController> {

private final static Logger logger = Logger.getLogger(SocketClient.class);
private final static Logger logger = LoggerFactory.getLogger(SocketClient.class);

private final Protocol<SocketDataController> protocol;

Expand Down
11 changes: 6 additions & 5 deletions uia.comm/src/main/java/uia/comm/SocketDataController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import java.util.Date;
import java.util.Iterator;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.comm.protocol.ProtocolMonitor;
import uia.utils.ByteUtils;
Expand All @@ -39,7 +40,7 @@
*/
public class SocketDataController implements DataController {

private final static Logger logger = Logger.getLogger(SocketDataController.class);
private final static Logger logger = LoggerFactory.getLogger(SocketDataController.class);

private final ProtocolMonitor<SocketDataController> monitor;

Expand Down Expand Up @@ -112,7 +113,7 @@ public synchronized boolean send(byte[] data, int times) {
return true;
}
else {
logger.fatal(String.format("%s> write count error!!", this.name));
logger.error(String.format("%s> write count error!!", this.name));
}
}
catch (Exception ex) {
Expand Down Expand Up @@ -206,7 +207,7 @@ synchronized boolean receive() throws IOException {
value = Arrays.copyOf(value, len);
for (byte b : value) {
if (this.monitor.getDataLength() > this.maxCache) {
logger.fatal(this.name + "> out of maxCchte:" + this.maxCache);
logger.error(this.name + "> out of maxCchte:" + this.maxCache);
this.monitor.reset();
}
this.monitor.read(b);
Expand Down Expand Up @@ -244,7 +245,7 @@ private void running() {
receive();
}
catch (Exception e) {
logger.fatal(socketChannel, e);
logger.error(socketChannel.toString() + " failed", e);
break;
}
}
Expand Down
7 changes: 4 additions & 3 deletions uia.comm/src/main/java/uia/comm/SocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.comm.protocol.Protocol;
import uia.comm.protocol.ProtocolEventArgs;
Expand All @@ -57,7 +58,7 @@ public enum ConnectionStyle {

private static int INST = 0;

private final static Logger logger = Logger.getLogger(SocketServer.class);
private final static Logger logger = LoggerFactory.getLogger(SocketServer.class);

private final int port;

Expand Down Expand Up @@ -388,7 +389,7 @@ public boolean start() {
this.ch.register(this.serverSelector, SelectionKey.OP_ACCEPT);
}
catch (Exception ex) {
logger.error(ex);
logger.error(ex.getMessage(), ex);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion uia.comm/src/main/java/uia/comm/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public interface Version {

public static final String NO = "2019711A";
public static final String NO = "0.5.200402A";

}
5 changes: 3 additions & 2 deletions uia.comm/src/main/java/uia/comm/VirtualSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import java.util.concurrent.LinkedBlockingQueue;

import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uia.utils.ByteUtils;

Expand All @@ -31,7 +32,7 @@
*/
public class VirtualSocketClient {

private final static Logger logger = Logger.getLogger(VirtualSocketClient.class);
private final static Logger logger = LoggerFactory.getLogger(VirtualSocketClient.class);

private SocketClient activeClient;

Expand Down
2 changes: 0 additions & 2 deletions uia.comm/src/test/java/uia/comm/NGSocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*******************************************************************************/
package uia.comm;

import org.apache.log4j.PropertyConfigurator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -38,7 +37,6 @@ public class NGSocketTest implements MessageManager, MessageCallOut, MessageCall
private final SocketServer server;

public NGSocketTest() throws Exception {
PropertyConfigurator.configure("log4j.properties");
this.server = new SocketServer(
new NGProtocol<SocketDataController>(),
PORT,
Expand Down
2 changes: 0 additions & 2 deletions uia.comm/src/test/java/uia/comm/SocketClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*******************************************************************************/
package uia.comm;

import org.apache.log4j.PropertyConfigurator;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -39,7 +38,6 @@ public class SocketClientTest {
private int size = 100000;

public SocketClientTest() {
PropertyConfigurator.configure("log4j.properties");
}

@Test
Expand Down
2 changes: 0 additions & 2 deletions uia.comm/src/test/java/uia/comm/SocketServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*******************************************************************************/
package uia.comm;

import org.apache.log4j.PropertyConfigurator;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -38,7 +37,6 @@ public class SocketServerTest {
private int size = 100000;

public SocketServerTest() {
PropertyConfigurator.configure("log4j.properties");
}

@Test
Expand Down
3 changes: 0 additions & 3 deletions uia.comm/src/test/java/uia/comm/XMLSocketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*******************************************************************************/
package uia.comm;

import org.apache.log4j.PropertyConfigurator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -38,8 +37,6 @@ public class XMLSocketTest implements MessageManager, MessageCallOut, MessageCal
private final SocketServer server;

public XMLSocketTest() throws Exception {
PropertyConfigurator.configure("log4j.properties");

this.server = new SocketServer(
new XMLProtocol<SocketDataController>("BBRAUN"),
PORT,
Expand Down
2 changes: 0 additions & 2 deletions uia.comm/src/test/java/uia/comm/my/ClientRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*******************************************************************************/
package uia.comm.my;

import org.junit.Assert;

import uia.comm.MessageCallIn;
import uia.comm.MessageCallOut;
import uia.comm.SocketDataController;
Expand Down

0 comments on commit ce72af9

Please sign in to comment.