java logging migration

This commit is contained in:
rusefi 2020-07-25 10:32:23 -04:00
parent 2c19ff8c48
commit 3f3ee0ef19
2 changed files with 12 additions and 9 deletions

View File

@ -10,10 +10,12 @@ import com.rusefi.Timeouts;
import com.rusefi.composite.CompositeEvent; import com.rusefi.composite.CompositeEvent;
import com.rusefi.composite.CompositeParser; import com.rusefi.composite.CompositeParser;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.*; import com.rusefi.core.MessagesCentral;
import com.rusefi.core.Pair;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.io.*; import com.rusefi.io.*;
import com.rusefi.io.commands.GetOutputsCommand; import com.rusefi.io.commands.GetOutputsCommand;
import com.rusefi.io.serial.PortHolder;
import com.rusefi.stream.LogicdataStreamFile; import com.rusefi.stream.LogicdataStreamFile;
import com.rusefi.stream.StreamFile; import com.rusefi.stream.StreamFile;
import com.rusefi.stream.TSHighSpeedLog; import com.rusefi.stream.TSHighSpeedLog;

View File

@ -1,7 +1,7 @@
package com.rusefi.proxy; package com.rusefi.proxy;
import com.devexperts.logging.Logging;
import com.opensr5.ConfigurationImage; import com.opensr5.ConfigurationImage;
import com.opensr5.Logger;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.io.ConnectionStateListener; import com.rusefi.io.ConnectionStateListener;
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
* see NetworkConnectorStartup * see NetworkConnectorStartup
*/ */
public class NetworkConnector { public class NetworkConnector {
private final static Logging log = Logging.getLogging(NetworkConnector.class);
public static SessionDetails runNetworkConnector(String authToken, String controllerPort, int serverPortForControllers, TcpIoStream.DisconnectListener disconnectListener) throws InterruptedException, IOException { public static SessionDetails runNetworkConnector(String authToken, String controllerPort, int serverPortForControllers, TcpIoStream.DisconnectListener disconnectListener) throws InterruptedException, IOException {
LinkManager controllerConnector = new LinkManager() LinkManager controllerConnector = new LinkManager()
.setCompositeLogicEnabled(false) .setCompositeLogicEnabled(false)
@ -43,18 +44,18 @@ public class NetworkConnector {
} }
}); });
Logger.CONSOLE.info("Connecting to controller..."); log.info("Connecting to controller...");
onConnected.await(1, TimeUnit.MINUTES); onConnected.await(1, TimeUnit.MINUTES);
if (onConnected.getCount() != 0) { if (onConnected.getCount() != 0) {
Logger.CONSOLE.info("Connection to controller failed"); log.info("Connection to controller failed");
return null; return null;
} }
return runNetworkConnector(serverPortForControllers, controllerConnector, Logger.CONSOLE, authToken, disconnectListener); return runNetworkConnector(serverPortForControllers, controllerConnector, authToken, disconnectListener);
} }
@NotNull @NotNull
private static SessionDetails runNetworkConnector(int serverPortForControllers, LinkManager linkManager, final Logger logger, String authToken, final TcpIoStream.DisconnectListener disconnectListener) throws IOException { private static SessionDetails runNetworkConnector(int serverPortForControllers, LinkManager linkManager, String authToken, final TcpIoStream.DisconnectListener disconnectListener) throws IOException {
IoStream targetEcuSocket = linkManager.getConnector().getBinaryProtocol().getStream(); IoStream targetEcuSocket = linkManager.getConnector().getBinaryProtocol().getStream();
HelloCommand.send(targetEcuSocket); HelloCommand.send(targetEcuSocket);
String helloResponse = HelloCommand.getHelloResponse(targetEcuSocket.getDataBuffer()); String helloResponse = HelloCommand.getHelloResponse(targetEcuSocket.getDataBuffer());
@ -76,11 +77,11 @@ public class NetworkConnector {
@Override @Override
protected void handleCommand(BinaryProtocolServer.Packet packet, TcpIoStream stream) throws IOException { protected void handleCommand(BinaryProtocolServer.Packet packet, TcpIoStream stream) throws IOException {
super.handleCommand(packet, stream); super.handleCommand(packet, stream);
logger.info("Relaying request to controller " + BinaryProtocol.findCommand(packet.getPacket()[0])); log.info("Relaying request to controller " + BinaryProtocol.findCommand(packet.getPacket()[0]));
targetEcuSocket.sendPacket(packet); targetEcuSocket.sendPacket(packet);
BinaryProtocolServer.Packet response = targetEcuSocket.readPacket(); BinaryProtocolServer.Packet response = targetEcuSocket.readPacket();
logger.info("Relaying response to proxy size=" + response.getPacket().length); log.info("Relaying response to proxy size=" + response.getPacket().length);
stream.sendPacket(response); stream.sendPacket(response);
} }
}; };