From 8677be41771cc05c389e5a429cdbab0c5f8da57b Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 12 Feb 2022 16:20:38 -0500 Subject: [PATCH] Console logging is a mess #3930 --- .../io/src/main/java/com/rusefi/io/DfuHelper.java | 6 ++++-- .../ui/src/main/java/com/rusefi/ConsoleUI.java | 10 +++++++--- .../ui/src/main/java/com/rusefi/Histograms.java | 6 +++++- .../ui/src/main/java/com/rusefi/SensorSnifferPane.java | 6 +++++- .../java/com/rusefi/ui/config/BaseConfigField.java | 8 +++++++- .../java/com/rusefi/ui/engine/EngineSnifferPanel.java | 7 ++++++- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java b/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java index ef2c5a35fb..8cf75dc7c1 100644 --- a/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java +++ b/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java @@ -1,6 +1,6 @@ package com.rusefi.io; -import com.rusefi.FileLog; +import com.devexperts.logging.Logging; import com.rusefi.RusEfiSignature; import com.rusefi.SignatureHelper; import com.rusefi.autoupdate.Autoupdate; @@ -11,10 +11,12 @@ import com.rusefi.ui.StatusConsumer; import javax.swing.*; import java.io.IOException; +import static com.devexperts.logging.Logging.getLogging; import static com.rusefi.Timeouts.SECOND; import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; public class DfuHelper { + private static final Logging log = getLogging(DfuHelper.class); private static final String PREFIX = "rusefi_bundle"; public static void sendDfuRebootCommand(IoStream stream, StatusConsumer messages) { @@ -41,7 +43,7 @@ public class DfuHelper { if (!bundleName.equalsIgnoreCase(signatureWithPrefix)) { String message = String.format("You have \"%s\" controller does not look right to program it with \"%s\"", s.getBundle(), bundleName); - FileLog.MAIN.logLine(message); + log.info(message); SwingUtilities.invokeLater(() -> { JOptionPane.showMessageDialog(parent, message); diff --git a/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java b/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java index 64b3c5fced..968f7051a1 100644 --- a/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java +++ b/java_console/ui/src/main/java/com/rusefi/ConsoleUI.java @@ -1,5 +1,6 @@ package com.rusefi; +import com.devexperts.logging.Logging; import com.rusefi.autodetect.PortDetector; import com.rusefi.autoupdate.AutoupdateUtil; import com.rusefi.binaryprotocol.BinaryProtocolLogger; @@ -13,6 +14,7 @@ import com.rusefi.io.serial.BaudRateHolder; import com.rusefi.maintenance.FirmwareFlasher; import com.rusefi.maintenance.VersionChecker; import com.rusefi.ui.*; +import com.rusefi.ui.config.BaseConfigField; import com.rusefi.ui.console.MainFrame; import com.rusefi.ui.console.TabbedPanel; import com.rusefi.ui.engine.EngineSnifferPanel; @@ -30,6 +32,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; +import static com.devexperts.logging.Logging.getLogging; import static com.rusefi.StartupFrame.setFrameIcon; import static com.rusefi.rusEFIVersion.CONSOLE_VERSION; import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; @@ -38,6 +41,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see StartupFrame */ public class ConsoleUI { + private static final Logging log = getLogging(ConsoleUI.class); private static final int DEFAULT_TAB_INDEX = 0; private static SensorCentral.SensorListener wrongVersionListener; @@ -68,9 +72,9 @@ public class ConsoleUI { MainFrame mainFrame = new MainFrame(this, tabbedPane); ConsoleUI.staticFrame = mainFrame.getFrame().getFrame(); setFrameIcon(ConsoleUI.staticFrame); - FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); + log.info("Console " + CONSOLE_VERSION); - FileLog.MAIN.logLine("Hardware: " + FirmwareFlasher.getHardwareKind()); + log.info("Hardware: " + FirmwareFlasher.getHardwareKind()); getConfig().getRoot().setProperty(PORT_KEY, port); getConfig().getRoot().setProperty(SPEED_KEY, BaudRateHolder.INSTANCE.baudRate); @@ -89,7 +93,7 @@ public class ConsoleUI { // TODO: this is a race if the ECU is slow to connect new ConnectionWatchdog(Timeouts.CONNECTION_RESTART_DELAY, () -> { uiContext.getLinkManager().execute(() -> { - FileLog.MAIN.logLine("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY); + log.info("ConnectionWatchdog.reconnectTimer restarting: " + Timeouts.CONNECTION_RESTART_DELAY); linkManager.restart(); }); }).start(); diff --git a/java_console/ui/src/main/java/com/rusefi/Histograms.java b/java_console/ui/src/main/java/com/rusefi/Histograms.java index e8dcae54fe..589f163577 100644 --- a/java_console/ui/src/main/java/com/rusefi/Histograms.java +++ b/java_console/ui/src/main/java/com/rusefi/Histograms.java @@ -1,12 +1,16 @@ package com.rusefi; +import com.devexperts.logging.Logging; import org.jetbrains.annotations.NotNull; import java.text.FieldPosition; import java.text.NumberFormat; import java.util.*; +import static com.devexperts.logging.Logging.getLogging; + public final class Histograms { + private static final Logging log = getLogging(Histograms.class); private static final String MAGIC = "total"; public static final double H_ACCURACY = 0.05; public static final int BOUND_LENGTH = (int) (Math.log(Long.MAX_VALUE) / Math.log(1.0 + H_ACCURACY)); @@ -115,7 +119,7 @@ public final class Histograms { confidence_bounds = new double[]{0.5 - H_CONFIDENCE * 0.5, 0.5, 0.5 + H_CONFIDENCE * 0.5}; confidence_separators = new String[]{"(", " [", "-", "-", "] ", ")"}; - FileLog.MAIN.logLine("BOUND_LENGTH=" + BOUND_LENGTH); + log.info("BOUND_LENGTH=" + BOUND_LENGTH); bounds = new long[BOUND_LENGTH]; bounds[0] = 0; diff --git a/java_console/ui/src/main/java/com/rusefi/SensorSnifferPane.java b/java_console/ui/src/main/java/com/rusefi/SensorSnifferPane.java index 2dc1a44a60..5e2b72e94a 100644 --- a/java_console/ui/src/main/java/com/rusefi/SensorSnifferPane.java +++ b/java_console/ui/src/main/java/com/rusefi/SensorSnifferPane.java @@ -1,5 +1,6 @@ package com.rusefi; +import com.devexperts.logging.Logging; import com.rusefi.config.generated.Fields; import com.rusefi.ui.RpmLabel; import com.rusefi.ui.RpmModel; @@ -19,11 +20,14 @@ import java.awt.event.ActionListener; import java.util.*; import java.util.List; +import static com.devexperts.logging.Logging.getLogging; + /** * Date: 12/21/13 * Andrey Belomutskiy, (c) 2013-2020 */ public class SensorSnifferPane { + private static final Logging log = getLogging(SensorSnifferPane.class); private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Analog_Chart"; private final TreeMap values = new TreeMap<>(); @@ -127,7 +131,7 @@ public class SensorSnifferPane { List keys = new ArrayList<>(values.keySet()); minX = keys.get(0); maxX = keys.get(keys.size() - 1); - FileLog.MAIN.logLine("Analog chart from " + minX + " to " + maxX); + log.info("Analog chart from " + minX + " to " + maxX); TreeSet sortedValues = new TreeSet<>(values.values()); List values = new ArrayList<>(sortedValues); diff --git a/java_console/ui/src/main/java/com/rusefi/ui/config/BaseConfigField.java b/java_console/ui/src/main/java/com/rusefi/ui/config/BaseConfigField.java index 6d0892e961..47e9ed8ea8 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/config/BaseConfigField.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/config/BaseConfigField.java @@ -1,11 +1,13 @@ package com.rusefi.ui.config; +import com.devexperts.logging.Logging; import com.opensr5.ConfigurationImage; import com.rusefi.FileLog; import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.config.Field; import com.rusefi.io.CommandQueue; import com.rusefi.io.ConnectionStatusLogic; +import com.rusefi.io.DfuHelper; import com.rusefi.io.LinkManager; import com.rusefi.ui.UIContext; import org.jetbrains.annotations.NotNull; @@ -14,7 +16,11 @@ import javax.swing.*; import java.awt.*; import java.nio.ByteBuffer; +import static com.devexperts.logging.Logging.getLogging; + public abstract class BaseConfigField { + private static final Logging log = getLogging(BaseConfigField.class); + protected final JLabel status = new JLabel("P"); private final JPanel panel = new JPanel(new BorderLayout()); private final UIContext uiContext; @@ -49,7 +55,7 @@ public abstract class BaseConfigField { protected void sendValue(Field field, String newValue) { String msg = field.setCommand() + " " + newValue; - FileLog.MAIN.logLine("Sending " + msg); + log.info("Sending " + msg); uiContext.getCommandQueue().write(msg); status.setText("S"); status.setToolTipText("Storing..."); diff --git a/java_console/ui/src/main/java/com/rusefi/ui/engine/EngineSnifferPanel.java b/java_console/ui/src/main/java/com/rusefi/ui/engine/EngineSnifferPanel.java index 86920693cd..bee11af310 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/engine/EngineSnifferPanel.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/engine/EngineSnifferPanel.java @@ -1,11 +1,13 @@ package com.rusefi.ui.engine; +import com.devexperts.logging.Logging; import com.rusefi.FileLog; import com.rusefi.config.generated.Fields; import com.rusefi.core.EngineState; import com.rusefi.core.Sensor; import com.rusefi.core.SensorCentral; import com.rusefi.ui.*; +import com.rusefi.ui.config.BaseConfigField; import com.rusefi.ui.config.BitConfigField; import com.rusefi.ui.config.ConfigField; import com.rusefi.ui.storage.Node; @@ -23,6 +25,8 @@ import java.awt.event.ActionListener; import java.util.*; import java.util.List; +import static com.devexperts.logging.Logging.getLogging; + /** * Engine Sniffer control consists of a set of {@link UpDownImage} *

@@ -34,6 +38,7 @@ import java.util.List; * @see com.rusefi.ui.test.WavePanelSandbox */ public class EngineSnifferPanel { + private static final Logging log = getLogging(EngineSnifferPanel.class); private static final int EFI_DEFAULT_CHART_SIZE = 180; public static final Comparator INSTANCE = new ImageOrderComparator(); private static final String HELP_URL = "http://rusefi.com/wiki/index.php?title=Manual:DevConsole#Digital_Chart"; @@ -239,7 +244,7 @@ public class EngineSnifferPanel { int index = getInsertIndex(name, images.keySet()); - FileLog.MAIN.logLine("Engine sniffer register channel " + name + " at idx " + index); + log.info("Engine sniffer register channel " + name + " at idx " + index); UpDownImage image = createImage(name); images.put(name, image);