Skip to content

Commit

Permalink
Merge pull request #39 from eupakhomov/0.5_switch_logging
Browse files Browse the repository at this point in the history
Switched logging to slf4j + logback.
  • Loading branch information
TVolden authored Apr 16, 2018
2 parents 9e67a71 + f71ba02 commit ae696b6
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 52 deletions.
24 changes: 14 additions & 10 deletions ocpp-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@
</scm>

<dependencies>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -53,16 +67,6 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
5 changes: 3 additions & 2 deletions ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ of this software and associated documentation files (the "Software"), to deal
import eu.chargetime.ocpp.feature.Feature;
import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;

Expand All @@ -43,7 +44,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public class Client
{
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(Client.class);
private static final Logger logger = LoggerFactory.getLogger(Client.class);

private Session session;
private final IFeatureRepository featureRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package eu.chargetime.ocpp;

import eu.chargetime.ocpp.model.*;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayDeque;

Expand Down Expand Up @@ -43,7 +44,7 @@ of this software and associated documentation files (the "Software"), to deal
* Must be overloaded to implement a specific format.
*/
public abstract class Communicator {
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(Communicator.class);
private static final Logger logger = LoggerFactory.getLogger(Communicator.class);

private RetryRunner retryRunner;
protected Radio radio;
Expand Down
5 changes: 3 additions & 2 deletions ocpp-common/src/main/java/eu/chargetime/ocpp/Queue.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package eu.chargetime.ocpp;

import eu.chargetime.ocpp.model.Request;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.UUID;
Expand Down Expand Up @@ -38,7 +39,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public class Queue
{
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(Queue.class);
private static final Logger logger = LoggerFactory.getLogger(Queue.class);

private HashMap<String, Request> requestQueue;

Expand Down
4 changes: 3 additions & 1 deletion ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import eu.chargetime.ocpp.feature.Feature;
import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -42,6 +43,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public class Server {

private static final Logger logger = LoggerFactory.getLogger(Server.class);
private HashMap<UUID, ISession> sessions;
private Listener listener;
private final IFeatureRepository featureRepository;
Expand Down
5 changes: 3 additions & 2 deletions ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import eu.chargetime.ocpp.feature.Feature;
import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -40,7 +41,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public class Session implements ISession {

private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(Session.class);
private static final Logger logger = LoggerFactory.getLogger(Session.class);

private final Communicator communicator;
private final Queue queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ of this software and associated documentation files (the "Software"), to deal

import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;

public class SimplePromiseFulfiller implements PromiseFulfiller {
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(SimplePromiseFulfiller.class);
private static final Logger logger = LoggerFactory.getLogger(SimplePromiseFulfiller.class);

@Override
public void fulfill(CompletableFuture<Confirmation> promise, SessionEvents eventHandler, Request request) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package eu.chargetime.ocpp.model;/*
package eu.chargetime.ocpp.model;
/*
ChargeTime.eu - Java-OCA-OCPP
MIT License
Expand Down
6 changes: 3 additions & 3 deletions ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ of this software and associated documentation files (the "Software"), to deal
import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;
import eu.chargetime.ocpp.model.SOAPHostInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.soap.SOAPMessage;
import java.io.IOException;
Expand All @@ -44,7 +44,7 @@ of this software and associated documentation files (the "Software"), to deal
import java.util.concurrent.Executors;

public class SOAPClient implements IClientAPI {
private static final Logger logger = LogManager.getLogger(SOAPClient.class);
private static final Logger logger = LoggerFactory.getLogger(SOAPClient.class);
private static final String WSDL_CHARGE_POINT = "eu/chargetime/ocpp/OCPP_ChargePointService_1.6.wsdl";

private Client client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ of this software and associated documentation files (the "Software"), to deal
*/

import eu.chargetime.ocpp.model.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand All @@ -39,7 +39,7 @@ of this software and associated documentation files (the "Software"), to deal
import javax.xml.soap.*;

public class SOAPCommunicator extends Communicator {
private static final Logger logger = LogManager.getLogger(SOAPCommunicator.class);
private static final Logger logger = LoggerFactory.getLogger(SOAPCommunicator.class);

private static final String HEADER_ACTION = "Action";
private static final String HEADER_MESSAGEID = "MessageID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ of this software and associated documentation files (the "Software"), to deal
SOFTWARE.
*/

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.NodeList;

import javax.xml.soap.SOAPException;
Expand All @@ -35,7 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
import java.util.concurrent.CompletableFuture;

public abstract class SOAPSyncHelper {
private static final Logger logger = LogManager.getLogger(SOAPSyncHelper.class);
private static final Logger logger = LoggerFactory.getLogger(SOAPSyncHelper.class);

private HashMap<String, CompletableFuture<SOAPMessage>> promises;

Expand Down
6 changes: 3 additions & 3 deletions ocpp-v1_6/src/main/java/eu/chargetime/ocpp/WSHttpHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ of this software and associated documentation files (the "Software"), to deal

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.soap.*;

Expand All @@ -37,7 +37,7 @@ of this software and associated documentation files (the "Software"), to deal
import java.io.OutputStream;

public class WSHttpHandler implements HttpHandler {
private static final Logger logger = LogManager.getLogger(WSHttpHandler.class);
private static final Logger logger = LoggerFactory.getLogger(WSHttpHandler.class);

private String wsdlResourceName;
private WSHttpHandlerEvents events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ of this software and associated documentation files (the "Software"), to deal
import eu.chargetime.ocpp.model.SOAPHostInfo;
import eu.chargetime.ocpp.model.SessionInformation;
import eu.chargetime.ocpp.utilities.TimeoutTimer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.soap.SOAPMessage;
import java.io.IOException;
Expand All @@ -39,7 +39,7 @@ of this software and associated documentation files (the "Software"), to deal
import java.util.concurrent.ExecutionException;

public class WebServiceListener implements Listener {
private static final Logger logger = LogManager.getLogger(WebServiceListener.class);
private static final Logger logger = LoggerFactory.getLogger(WebServiceListener.class);
private static final String WSDL_CENTRAL_SYSTEM = "eu/chargetime/ocpp/OCPP_CentralSystemService_1.6.wsdl";
private final IServerSessionFactory sessionFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ of this software and associated documentation files (the "Software"), to deal
SOFTWARE.
*/

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;

public class WebServiceReceiver extends SOAPSyncHelper implements Receiver {
private static final Logger logger = LogManager.getLogger(WebServiceReceiver.class);
private static final Logger logger = LoggerFactory.getLogger(WebServiceReceiver.class);

private RadioEvents events;
SOAPConnection soapConnection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package eu.chargetime.ocpp;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
Expand Down Expand Up @@ -35,7 +36,7 @@ of this software and associated documentation files (the "Software"), to deal
*/

public class WebServiceTransmitter extends SOAPSyncHelper implements Transmitter {
private static final Logger logger = LogManager.getLogger(WebServiceTransmitter.class);
private static final Logger logger = LoggerFactory.getLogger(WebServiceTransmitter.class);

SOAPConnection soapConnection;
private String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ of this software and associated documentation files (the "Software"), to deal
*/

import eu.chargetime.ocpp.model.SessionInformation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.java_websocket.WebSocket;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_6455;
Expand All @@ -37,14 +36,16 @@ of this software and associated documentation files (the "Software"), to deal
import org.java_websocket.protocols.Protocol;
import org.java_websocket.server.DefaultSSLWebSocketServerFactory;
import org.java_websocket.server.WebSocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLContext;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.HashMap;

public class WebSocketListener implements Listener {
private static final Logger logger = LogManager.getLogger(WebSocketListener.class);
private static final Logger logger = LoggerFactory.getLogger(WebSocketListener.class);
private final IServerSessionFactory sessionFactory;

private WebSocketServer server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ of this software and associated documentation files (the "Software"), to deal
SOFTWARE.
*/

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.java_websocket.extensions.IExtension;
import org.java_websocket.handshake.ServerHandshake;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.java_websocket.protocols.IProtocol;
import org.java_websocket.protocols.Protocol;

Expand All @@ -49,7 +52,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public class WebSocketTransmitter implements Transmitter
{
private static final Logger logger = LogManager.getLogger(WebSocketTransmitter.class);
private static final Logger logger = LoggerFactory.getLogger(WebSocketTransmitter.class);

private WebSocketClient client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import eu.chargetime.ocpp.PropertyConstraintException;
import eu.chargetime.ocpp.model.Validatable;
import eu.chargetime.ocpp.utilities.ModelUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
Expand All @@ -41,7 +41,7 @@
@XmlRootElement
@XmlType(propOrder = {"value", "context", "format", "measurand", "phase", "location", "unit"})
public class SampledValue implements Validatable {
private static final Logger logger = LogManager.getLogger(SampledValue.class);
private static final Logger logger = LoggerFactory.getLogger(SampledValue.class);

private String value;
private String context;
Expand Down

0 comments on commit ae696b6

Please sign in to comment.