reducing logging mess

only:uaefi
This commit is contained in:
Andrey 2024-09-18 10:56:55 -04:00
parent 80b227b2fa
commit f25772dc7d
18 changed files with 139 additions and 138 deletions

View File

@ -0,0 +1,78 @@
package com.rusefi;
import com.devexperts.logging.FileLogger;
import com.opensr5.Logger;
import org.jetbrains.annotations.Nullable;
import java.io.*;
public enum AutotestLogging {
INSTANCE;
public static String currentLogName;
@Nullable
private OutputStream fileLog; // null if not opened yet or already closed
public static boolean suspendLogging;
public synchronized void logLine(String fullLine) {
String withDate = FileLog.getDate() + Logger.END_OF_TIMESTAND_TAG + fullLine;
System.out.println(withDate);
if (suspendLogging)
return;
if (fileLog == null)
return;
try {
fileLog.write((withDate + "\r\n").getBytes());
fileLog.flush();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
private FileOutputStream openLog() throws FileNotFoundException {
FileLogger.createFolderIfNeeded();
String shortFileName = name() + "_rfi_report_" + FileLogger.date;
currentLogName = shortFileName + ".csv";
String fullFileName = FileLogger.DIR + currentLogName;
rlog("Writing to " + fullFileName);
return new FileOutputStream(fullFileName, true);
}
public void start() {
if (fileLog != null)
return;
try {
fileLog = openLog();
} catch (FileNotFoundException e) {
// Access is denied would be an example of a legit exception to happen here
return;
}
}
public synchronized void close() {
if (fileLog == null)
return; // already closed
try {
rlog("Closing file...");
fileLog.close();
fileLog = null;
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
private static void rlog(String msg) {
System.out.println("rlog " + msg);
}
public void log(Throwable exception) {
if (fileLog == null)
throw new NullPointerException("fileLog while " + exception);
OutputStreamWriter os = new OutputStreamWriter(fileLog);
exception.printStackTrace(new PrintWriter(os));
}
}

View File

@ -1,7 +1,6 @@
package com.rusefi; package com.rusefi;
import com.rusefi.autotest.ControllerConnectorState; import com.rusefi.autotest.ControllerConnectorState;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.Integration; import com.rusefi.config.generated.Integration;
import com.rusefi.enums.engine_type_e; import com.rusefi.enums.engine_type_e;
import com.rusefi.functional_tests.EcuTestHelper; import com.rusefi.functional_tests.EcuTestHelper;
@ -20,7 +19,7 @@ public class EnduranceTestUtility {
public static void main(String[] args) { public static void main(String[] args) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
int count = parseCount(args); int count = parseCount(args);
FileLog.MAIN.logLine("Running " + count + " cycles"); AutotestLogging.INSTANCE.logLine("Running " + count + " cycles");
try { try {
LinkManager linkManager = ControllerConnectorState.getLinkManager(); LinkManager linkManager = ControllerConnectorState.getLinkManager();
@ -35,19 +34,19 @@ public class EnduranceTestUtility {
EcuTestHelper.currentEngineType = engine_type_e.DEFAULT_FRANKENSO.ordinal(); EcuTestHelper.currentEngineType = engine_type_e.DEFAULT_FRANKENSO.ordinal();
sendBlockingCommand("set " + Integration.CMD_ENGINE_TYPE + " " + 28, Timeouts.SET_ENGINE_TIMEOUT, commandQueue); sendBlockingCommand("set " + Integration.CMD_ENGINE_TYPE + " " + 28, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2); sleepSeconds(2);
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++"); AutotestLogging.INSTANCE.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
System.exit(-1); System.exit(-1);
} }
FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); AutotestLogging.INSTANCE.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ YES YES YES " + count + " +++++++++++++++"); AutotestLogging.INSTANCE.logLine("++++++++++++++++++++++++++++++++++++ YES YES YES " + count + " +++++++++++++++");
FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); AutotestLogging.INSTANCE.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
long totalTime = System.currentTimeMillis() - start; long totalTime = System.currentTimeMillis() - start;
long minutes = totalTime / 1000 / 60; long minutes = totalTime / 1000 / 60;
FileLog.MAIN.logLine("In " + minutes + " minutes"); AutotestLogging.INSTANCE.logLine("In " + minutes + " minutes");
} }
private static int parseCount(String[] args) { private static int parseCount(String[] args) {

View File

@ -118,7 +118,7 @@ public class IoUtil {
if (!haveResponse) if (!haveResponse)
throw new IllegalStateException("No response from simulator"); throw new IllegalStateException("No response from simulator");
listener.remove(); listener.remove();
FileLog.MAIN.logLine("Got first signal in " + (System.currentTimeMillis() - waitStart) + "ms"); AutotestLogging.INSTANCE.logLine("Got first signal in " + (System.currentTimeMillis() - waitStart) + "ms");
} }
public static void connectToSimulator(LinkManager linkManager, boolean startProcess) throws InterruptedException { public static void connectToSimulator(LinkManager linkManager, boolean startProcess) throws InterruptedException {
@ -159,7 +159,7 @@ public class IoUtil {
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public static void sleepSeconds(int seconds) { public static void sleepSeconds(int seconds) {
FileLog.MAIN.logLine("Sleeping " + seconds + " seconds"); AutotestLogging.INSTANCE.logLine("Sleeping " + seconds + " seconds");
try { try {
Thread.sleep(seconds * 1000L); Thread.sleep(seconds * 1000L);
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@ -36,14 +36,14 @@ public class SimulatorExecHelper {
*/ */
private static void runSimulator(CountDownLatch simulatorStarted) { private static void runSimulator(CountDownLatch simulatorStarted) {
Thread.currentThread().setName("Main simulation"); Thread.currentThread().setName("Main simulation");
FileLog.MAIN.logLine("runSimulator..."); AutotestLogging.INSTANCE.logLine("runSimulator...");
try { try {
FileLog.MAIN.logLine("Binary size: " + new File(SIMULATOR_BINARY).length()); AutotestLogging.INSTANCE.logLine("Binary size: " + new File(SIMULATOR_BINARY).length());
FileLog.MAIN.logLine("Executing " + SIMULATOR_BINARY); AutotestLogging.INSTANCE.logLine("Executing " + SIMULATOR_BINARY);
simulatorProcess = Runtime.getRuntime().exec(SIMULATOR_BINARY); simulatorProcess = Runtime.getRuntime().exec(SIMULATOR_BINARY);
FileLog.MAIN.logLine("simulatorProcess: " + simulatorProcess); AutotestLogging.INSTANCE.logLine("simulatorProcess: " + simulatorProcess);
dumpProcessOutput(simulatorProcess, simulatorStarted); dumpProcessOutput(simulatorProcess, simulatorStarted);
} catch (Exception err) { } catch (Exception err) {
@ -55,7 +55,7 @@ public class SimulatorExecHelper {
} }
try { try {
FileLog.MAIN.logLine("exitValue: " + simulatorProcess.exitValue()); AutotestLogging.INSTANCE.logLine("exitValue: " + simulatorProcess.exitValue());
} catch (Exception err) { } catch (Exception err) {
log.warn("Error reading exit value", err); log.warn("Error reading exit value", err);
} }
@ -99,7 +99,7 @@ public class SimulatorExecHelper {
String prefix = "ERROR from console: "; String prefix = "ERROR from console: ";
Consumer<String> PRINT_AND_LOG = string -> { Consumer<String> PRINT_AND_LOG = string -> {
System.out.println(prefix + string); System.out.println(prefix + string);
FileLog.SIMULATOR_CONSOLE.logLine(string); log.info(string);
}; };
readAndPrint(PRINT_AND_LOG, err); readAndPrint(PRINT_AND_LOG, err);
@ -111,7 +111,7 @@ public class SimulatorExecHelper {
static void destroy() { static void destroy() {
if (simulatorProcess != null) { if (simulatorProcess != null) {
FileLog.MAIN.logLine("Destroying sub-process..."); log.info("Destroying sub-process...");
simulatorProcess.destroy(); simulatorProcess.destroy();
} }
} }
@ -119,7 +119,7 @@ public class SimulatorExecHelper {
public static void startSimulator() throws InterruptedException { public static void startSimulator() throws InterruptedException {
if (!new File(SIMULATOR_BINARY).exists()) if (!new File(SIMULATOR_BINARY).exists())
throw new IllegalStateException(SIMULATOR_BINARY + " not found"); throw new IllegalStateException(SIMULATOR_BINARY + " not found");
FileLog.MAIN.logLine("startSimulator..."); AutotestLogging.INSTANCE.logLine("startSimulator...");
CountDownLatch simulatorStarted = new CountDownLatch(1); CountDownLatch simulatorStarted = new CountDownLatch(1);
new Thread(() -> runSimulator(simulatorStarted), "simulator process").start(); new Thread(() -> runSimulator(simulatorStarted), "simulator process").start();
simulatorStarted.await(1, TimeUnit.MINUTES); simulatorStarted.await(1, TimeUnit.MINUTES);

View File

@ -27,8 +27,7 @@ public class SimulatorFunctionalTestLauncher {
// } // }
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
FileLog.SIMULATOR_CONSOLE.start(); AutotestLogging.INSTANCE.start();
FileLog.MAIN.start();
boolean failed = false; boolean failed = false;
try { try {
@ -45,11 +44,11 @@ public class SimulatorFunctionalTestLauncher {
if (failed) if (failed)
System.exit(-1); System.exit(-1);
isHappy = true; isHappy = true;
FileLog.MAIN.logLine("*******************************************************************************"); AutotestLogging.INSTANCE.logLine("*******************************************************************************");
FileLog.MAIN.logLine("**** SimulatorFunctionalTestLauncher Looks good! *****************************"); AutotestLogging.INSTANCE.logLine("**** SimulatorFunctionalTestLauncher Looks good! *****************************");
FileLog.MAIN.logLine("*******************************************************************************"); AutotestLogging.INSTANCE.logLine("*******************************************************************************");
long time = (System.currentTimeMillis() - start) / 1000; long time = (System.currentTimeMillis() - start) / 1000;
FileLog.MAIN.logLine("Done in " + time + "secs"); AutotestLogging.INSTANCE.logLine("Done in " + time + "secs");
System.exit(0); // this is a safer method eliminating the issue of non-daemon threads System.exit(0); // this is a safer method eliminating the issue of non-daemon threads
} }

View File

@ -1,7 +1,6 @@
package com.rusefi; package com.rusefi;
import com.devexperts.logging.Logging; import com.devexperts.logging.Logging;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.Integration; import com.rusefi.config.generated.Integration;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.functional_tests.EcuTestHelper; import com.rusefi.functional_tests.EcuTestHelper;
@ -108,14 +107,14 @@ public class TestingUtils {
public static EngineChart nextChart(CommandQueue commandQueue) { public static EngineChart nextChart(CommandQueue commandQueue) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
EngineChart chart = EngineChartParser.unpackToMap(getNextWaveChart(commandQueue)); EngineChart chart = EngineChartParser.unpackToMap(getNextWaveChart(commandQueue));
FileLog.MAIN.logLine("AUTOTEST nextChart() in " + (System.currentTimeMillis() - start)); AutotestLogging.INSTANCE.logLine("AUTOTEST nextChart() in " + (System.currentTimeMillis() - start));
return chart; return chart;
} }
static String getNextWaveChart(CommandQueue commandQueue) { static String getNextWaveChart(CommandQueue commandQueue) {
IoUtil.sendBlockingCommand(Integration.CMD_RESET_ENGINE_SNIFFER, commandQueue); IoUtil.sendBlockingCommand(Integration.CMD_RESET_ENGINE_SNIFFER, commandQueue);
String result = getEngineChart(commandQueue); String result = getEngineChart(commandQueue);
FileLog.MAIN.logLine("current chart: " + result); AutotestLogging.INSTANCE.logLine("current chart: " + result);
return result; return result;
} }
@ -130,7 +129,7 @@ public class TestingUtils {
final AtomicReference<String> result = new AtomicReference<>(); final AtomicReference<String> result = new AtomicReference<>();
FileLog.MAIN.logLine("waiting for next chart"); AutotestLogging.INSTANCE.logLine("waiting for next chart");
commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Integration.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback<String>() { commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Integration.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback<String>() {
@Override @Override
public void onUpdate(String value) { public void onUpdate(String value) {

View File

@ -1,6 +1,6 @@
package com.rusefi.autotest; package com.rusefi.autotest;
import com.rusefi.FileLog; import com.rusefi.AutotestLogging;
import com.rusefi.IoUtil; import com.rusefi.IoUtil;
import com.rusefi.TestingUtils; import com.rusefi.TestingUtils;
import com.rusefi.autodetect.PortDetector; import com.rusefi.autodetect.PortDetector;
@ -34,7 +34,7 @@ public class ControllerConnectorState {
* test exact numbers yet * test exact numbers yet
*/ */
TestingUtils.isRealHardware = true; TestingUtils.isRealHardware = true;
FileLog.MAIN.start(); AutotestLogging.INSTANCE.start();
String port = System.getenv("HARDWARE_CI_SERIAL_DEVICE"); String port = System.getenv("HARDWARE_CI_SERIAL_DEVICE");
if (port == null) { if (port == null) {

View File

@ -1,34 +1,20 @@
package com.rusefi; package com.rusefi;
import com.devexperts.logging.FileLogger; import com.devexperts.logging.FileLogger;
import com.devexperts.logging.Logging;
import com.opensr5.Logger; import com.opensr5.Logger;
import com.rusefi.util.LazyFile;
import com.rusefi.util.LazyFileImpl;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
/** /**
* what the hell is this anyway? todo: migrate to log4j2 * what the hell is this anyway? rename this utility class?
* 6/30/13 * 6/30/13
* Andrey Belomutskiy, (c) 2013-2020 * Andrey Belomutskiy, (c) 2013-2020
*/ */
@Deprecated public class FileLog {
public enum FileLog {
MAIN,
SIMULATOR_CONSOLE;
public static final String LOG_INFO_TEXT = "Writing logs to '" + FileLogger.DIR + "'"; public static final String LOG_INFO_TEXT = "Writing logs to '" + FileLogger.DIR + "'";
public static final String OS_VERSION = "os.version"; public static final String OS_VERSION = "os.version";
public static String currentLogName;
@Nullable
private OutputStream fileLog; // null if not opened yet or already closed
public static boolean suspendLogging;
FileLog() { FileLog() {
} }
@ -37,17 +23,6 @@ public enum FileLog {
return FileLogger.getDate(); return FileLogger.getDate();
} }
public void start() {
if (fileLog != null)
return;
try {
fileLog = openLog();
} catch (FileNotFoundException e) {
// Access is denied would be an example of a legit exception to happen here
return;
}
}
public static boolean isLinux() { public static boolean isLinux() {
return getOsName().equalsIgnoreCase("Linux"); return getOsName().equalsIgnoreCase("Linux");
} }
@ -63,52 +38,4 @@ public enum FileLog {
public static boolean isWindows() { public static boolean isWindows() {
return getOsName().contains("Windows"); return getOsName().contains("Windows");
} }
private FileOutputStream openLog() throws FileNotFoundException {
FileLogger.createFolderIfNeeded();
String shortFileName = name() + "_rfi_report_" + FileLogger.date;
currentLogName = shortFileName + ".csv";
String fullFileName = FileLogger.DIR + currentLogName;
rlog("Writing to " + fullFileName);
return new FileOutputStream(fullFileName, true);
}
public synchronized void logLine(String fullLine) {
String withDate = getDate() + Logger.END_OF_TIMESTAND_TAG + fullLine;
System.out.println(withDate);
if (suspendLogging)
return;
if (fileLog == null)
return;
try {
fileLog.write((withDate + "\r\n").getBytes());
fileLog.flush();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
public synchronized void close() {
if (fileLog == null)
return; // already closed
try {
rlog("Closing file...");
fileLog.close();
fileLog = null;
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
private static void rlog(String msg) {
System.out.println("rlog " + msg);
}
public void log(Throwable exception) {
if (fileLog == null)
throw new NullPointerException("fileLog while " + exception);
OutputStreamWriter os = new OutputStreamWriter(fileLog);
exception.printStackTrace(new PrintWriter(os));
}
} }

View File

@ -15,7 +15,6 @@ import com.rusefi.ui.console.MainFrame;
import com.rusefi.ui.console.TabbedPanel; import com.rusefi.ui.console.TabbedPanel;
import com.rusefi.ui.engine.EngineSnifferPanel; import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.knock.KnockPane; import com.rusefi.ui.knock.KnockPane;
import com.rusefi.ui.logview.LogViewer;
import com.rusefi.ui.lua.LuaScriptPanel; import com.rusefi.ui.lua.LuaScriptPanel;
import com.rusefi.ui.util.DefaultExceptionHandler; import com.rusefi.ui.util.DefaultExceptionHandler;
import com.rusefi.ui.util.JustOneInstance; import com.rusefi.ui.util.JustOneInstance;
@ -95,8 +94,9 @@ public class ConsoleUI {
if (!LinkManager.isLogViewerMode(port)) if (!LinkManager.isLogViewerMode(port))
engineSnifferPanel.setOutpinListener(uiContext.getLinkManager().getEngineState()); engineSnifferPanel.setOutpinListener(uiContext.getLinkManager().getEngineState());
if (LinkManager.isLogViewerMode(port)) // what is LogViewer? is this all dead?
tabbedPane.addTab("Log Viewer", new LogViewer(uiContext, engineSnifferPanel)); // if (LinkManager.isLogViewerMode(port))
// tabbedPane.addTab("Log Viewer", new LogViewer(uiContext, engineSnifferPanel));
uiContext.DetachedRepositoryINSTANCE.init(getConfig().getRoot().getChild("detached")); uiContext.DetachedRepositoryINSTANCE.init(getConfig().getRoot().getChild("detached"));
uiContext.DetachedRepositoryINSTANCE.load(); uiContext.DetachedRepositoryINSTANCE.load();
@ -209,7 +209,6 @@ public class ConsoleUI {
} }
static void startUi(String[] args) throws InterruptedException, InvocationTargetException { static void startUi(String[] args) throws InterruptedException, InvocationTargetException {
FileLog.MAIN.start();
if (ConnectionAndMeta.saveReadmeHtmlToFile()) { if (ConnectionAndMeta.saveReadmeHtmlToFile()) {
new Thread(ConsoleUI::writeReadmeFile).start(); new Thread(ConsoleUI::writeReadmeFile).start();
} }
@ -218,7 +217,7 @@ public class ConsoleUI {
log.info("OS version: " + System.getProperty(FileLog.OS_VERSION)); log.info("OS version: " + System.getProperty(FileLog.OS_VERSION));
getConfig().load(); getConfig().load();
FileLog.suspendLogging = getConfig().getRoot().getBoolProperty(GaugesPanel.DISABLE_LOGS); AutotestLogging.suspendLogging = getConfig().getRoot().getBoolProperty(GaugesPanel.DISABLE_LOGS);
DefaultExceptionHandler.install(); DefaultExceptionHandler.install();
// not very useful? VersionChecker.start(); // not very useful? VersionChecker.start();
SwingUtilities.invokeAndWait(() -> awtCode(args)); SwingUtilities.invokeAndWait(() -> awtCode(args));

View File

@ -1,7 +1,9 @@
package com.rusefi; package com.rusefi;
import com.devexperts.logging.Logging;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpConnector;
import com.rusefi.ui.logview.LogViewer;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -11,12 +13,14 @@ import java.io.IOException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.ui.util.UiUtils.setToolTip; import static com.rusefi.ui.util.UiUtils.setToolTip;
public class SimulatorHelper { public class SimulatorHelper {
private final static ThreadFactory THREAD_FACTORY = new NamedThreadFactory("SimulatorHelper"); private final static ThreadFactory THREAD_FACTORY = new NamedThreadFactory("SimulatorHelper");
public static final String BINARY = "rusefi_simulator.exe"; public static final String BINARY = "rusefi_simulator.exe";
private static Process process; private static Process process;
private static final Logging log = getLogging(SimulatorHelper.class);
public static boolean isBinaryHere() { public static boolean isBinaryHere() {
return new File(BINARY).exists(); return new File(BINARY).exists();
@ -29,14 +33,13 @@ public class SimulatorHelper {
private static void startSimulator() { private static void startSimulator() {
LinkManager.isSimulationMode = true; LinkManager.isSimulationMode = true;
FileLog.MAIN.logLine("Executing simulator " + BINARY); log.info("Executing simulator " + BINARY);
THREAD_FACTORY.newThread(new Runnable() { THREAD_FACTORY.newThread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
FileLog.SIMULATOR_CONSOLE.start();
process = Runtime.getRuntime().exec(BINARY); process = Runtime.getRuntime().exec(BINARY);
FileLog.MAIN.logLine("Executing simulator " + BINARY + "=" + process); log.info("Executing simulator " + BINARY + "=" + process);
SimulatorExecHelper.dumpProcessOutput(process, new CountDownLatch(1)); SimulatorExecHelper.dumpProcessOutput(process, new CountDownLatch(1));
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
@ -57,7 +60,7 @@ public class SimulatorHelper {
} }
if (!isPortOpened) if (!isPortOpened)
throw new IllegalStateException("Port not opened?"); throw new IllegalStateException("Port not opened?");
FileLog.MAIN.logLine("Port " + TcpConnector.DEFAULT_PORT + " is alive"); log.info("Port " + TcpConnector.DEFAULT_PORT + " is alive");
new ConsoleUI("" + TcpConnector.DEFAULT_PORT); new ConsoleUI("" + TcpConnector.DEFAULT_PORT);
} }

View File

@ -1,5 +1,6 @@
package com.rusefi.maintenance; package com.rusefi.maintenance;
import com.devexperts.logging.Logging;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.io.UpdateOperationCallbacks; import com.rusefi.io.UpdateOperationCallbacks;
@ -9,6 +10,8 @@ import java.awt.event.ActionEvent;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import static com.devexperts.logging.Logging.getLogging;
/** /**
* This code automates drivers unpacking and installation * This code automates drivers unpacking and installation
* new, DFU Virtual Comport and ST-Link drivers are installed * new, DFU Virtual Comport and ST-Link drivers are installed
@ -16,6 +19,7 @@ import java.io.FileNotFoundException;
* See https://github.com/rusefi/rusefi/tree/master/misc/install_st * See https://github.com/rusefi/rusefi/tree/master/misc/install_st
*/ */
public class DriverInstall { public class DriverInstall {
private static final Logging log = getLogging(DriverInstall.class);
private static final String FOLDER = "../drivers"; private static final String FOLDER = "../drivers";
private static final String SELF_UNCOMPRESSING_ARCHIVE = "silent_st_drivers2.exe"; private static final String SELF_UNCOMPRESSING_ARCHIVE = "silent_st_drivers2.exe";
private static final String YES = " -y"; private static final String YES = " -y";
@ -44,11 +48,11 @@ public class DriverInstall {
} }
private static void installDrivers(UpdateOperationCallbacks wnd) { private static void installDrivers(UpdateOperationCallbacks wnd) {
FileLog.MAIN.logLine("IsWindows=" + FileLog.isWindows()); log.info("IsWindows=" + FileLog.isWindows());
if (!new File(FOLDER).exists()) { if (!new File(FOLDER).exists()) {
String message = FOLDER + " not found"; String message = FOLDER + " not found";
wnd.appendLine(message); wnd.appendLine(message);
FileLog.MAIN.logLine(message); log.info(message);
return; return;
} }
try { try {

View File

@ -48,7 +48,7 @@ public class VersionChecker {
try { try {
instance.readAndProcess(); instance.readAndProcess();
} catch (IOException e) { } catch (IOException e) {
FileLog.MAIN.logLine("Failed to read from " + VERSIONS_URL + e); log.error("Failed to read from " + VERSIONS_URL + e);
} }
} }
}, "version checker"); }, "version checker");
@ -131,7 +131,7 @@ public class VersionChecker {
try { try {
version = Integer.parseInt(tokens[1]); version = Integer.parseInt(tokens[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
FileLog.MAIN.logLine("Error processing version [" + firmwareString + "]"); log.error("Error processing version [" + firmwareString + "]");
return; return;
} }
if (version == previousReportedVersion) { if (version == previousReportedVersion) {

View File

@ -1,10 +1,12 @@
package com.rusefi.sensor_logs; package com.rusefi.sensor_logs;
import com.devexperts.logging.Logging;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.NamedThreadFactory; import com.rusefi.NamedThreadFactory;
import com.rusefi.Timeouts; import com.rusefi.Timeouts;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.maintenance.VersionChecker;
import com.rusefi.tools.online.Online; import com.rusefi.tools.online.Online;
import com.rusefi.tools.online.UploadResult; import com.rusefi.tools.online.UploadResult;
import com.rusefi.ui.AuthTokenPanel; import com.rusefi.ui.AuthTokenPanel;
@ -17,7 +19,10 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.devexperts.logging.Logging.getLogging;
public class BinarySensorLogRestarter implements SensorLog { public class BinarySensorLogRestarter implements SensorLog {
private static final Logging log = getLogging(BinarySensorLogRestarter.class);
private final static Executor UPLOAD_EXECUTOR = Executors.newSingleThreadExecutor(new NamedThreadFactory("BinarySensorLogRestarter")); private final static Executor UPLOAD_EXECUTOR = Executors.newSingleThreadExecutor(new NamedThreadFactory("BinarySensorLogRestarter"));
private BinarySensorLog logger; private BinarySensorLog logger;
@ -64,7 +69,7 @@ public class BinarySensorLogRestarter implements SensorLog {
} }
private void scheduleUpload(String fileName) { private void scheduleUpload(String fileName) {
FileLog.MAIN.logLine("Will upload " + fileName); log.error("Will upload " + fileName);
UPLOAD_EXECUTOR.execute(new Runnable() { UPLOAD_EXECUTOR.execute(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -150,12 +150,6 @@ public class GaugesPanel {
@NotNull @NotNull
private JPopupMenu createMenu(final Node config) { private JPopupMenu createMenu(final Node config) {
JPopupMenu menu = new JPopupMenu(); JPopupMenu menu = new JPopupMenu();
final JCheckBoxMenuItem saveDetailedLogs = new JCheckBoxMenuItem("Save detailed logs");
saveDetailedLogs.addActionListener(e -> {
FileLog.suspendLogging = !saveDetailedLogs.isSelected();
getConfig().getRoot().setBoolProperty(DISABLE_LOGS, FileLog.suspendLogging);
});
saveDetailedLogs.setSelected(!FileLog.suspendLogging);
final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM"); final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM");
final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands"); final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands");
@ -176,7 +170,6 @@ public class GaugesPanel {
showCommandsItem.setSelected(showMessagesPanel); showCommandsItem.setSelected(showMessagesPanel);
menu.add(showCommandsItem); menu.add(showCommandsItem);
menu.add(new JPopupMenu.Separator()); menu.add(new JPopupMenu.Separator());
menu.add(saveDetailedLogs);
menu.add(new JPopupMenu("Reset Config")); // todo looks like not working menu.add(new JPopupMenu("Reset Config")); // todo looks like not working
return menu; return menu;
} }

View File

@ -2,7 +2,6 @@ package com.rusefi.ui;
import com.rusefi.ConsoleUI; import com.rusefi.ConsoleUI;
import com.rusefi.core.MessagesCentral; import com.rusefi.core.MessagesCentral;
import com.rusefi.io.CommandQueue;
import com.rusefi.ui.logview.LogViewer; import com.rusefi.ui.logview.LogViewer;
import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.UiUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -51,7 +51,6 @@ public class MainFrame {
* here we would close the log file * here we would close the log file
*/ */
log.info("onWindowClosed"); log.info("onWindowClosed");
FileLog.MAIN.close();
} }
}; };

View File

@ -1,11 +1,13 @@
package com.rusefi.ui.logview; package com.rusefi.ui.logview;
import com.devexperts.logging.FileLogger; import com.devexperts.logging.FileLogger;
import com.devexperts.logging.Logging;
import com.rusefi.ConsoleUI; import com.rusefi.ConsoleUI;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.file.FileUtils; import com.rusefi.file.FileUtils;
import com.rusefi.sensor_logs.BinarySensorLogRestarter;
import com.rusefi.ui.ChartRepository; import com.rusefi.ui.ChartRepository;
import com.rusefi.ui.LogDownloader; import com.rusefi.ui.LogDownloader;
import com.rusefi.ui.UIContext; import com.rusefi.ui.UIContext;
@ -22,7 +24,10 @@ import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.util.Arrays; import java.util.Arrays;
import static com.devexperts.logging.Logging.getLogging;
/** /**
* TODO: what is LogViewer? is this all dead?
* This tab is the entry point of rusEfi own log browser * This tab is the entry point of rusEfi own log browser
* <p/> * <p/>
* <p/> * <p/>
@ -37,6 +42,7 @@ public class LogViewer extends JPanel {
return pathname.getName().contains("MAIN_rfi_report"); return pathname.getName().contains("MAIN_rfi_report");
} }
}; };
private static final Logging log = getLogging(LogViewer.class);
public static final String DEFAULT_LOG_LOCATION = FileLogger.DIR; public static final String DEFAULT_LOG_LOCATION = FileLogger.DIR;
private final JLabel folderLabel = new JLabel(); private final JLabel folderLabel = new JLabel();
private final JLabel fileLabel = new JLabel(); private final JLabel fileLabel = new JLabel();
@ -128,14 +134,6 @@ public class LogViewer extends JPanel {
while (files.length > index && uiContext.getLinkManager().isLogViewer()) { while (files.length > index && uiContext.getLinkManager().isLogViewer()) {
File file = files[index]; File file = files[index];
if (file.getName().endsWith(FileLog.currentLogName)) {
/**
* we do not want to view the log file we've just started to produce.
* We are here if the logs are newer then our current time - remember about fime zone differences
*/
index++;
continue;
}
openFile(file); openFile(file);
break; break;
} }
@ -185,7 +183,7 @@ public class LogViewer extends JPanel {
engineState.registerStringValueAction(Fields.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback<String>() { engineState.registerStringValueAction(Fields.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback<String>() {
@Override @Override
public void onUpdate(String value) { public void onUpdate(String value) {
FileLog.MAIN.logLine("Got wave_chart: " + value); log.info("Got wave_chart: " + value);
ChartRepository.getInstance().addChart(value); ChartRepository.getInstance().addChart(value);
} }

View File

@ -135,7 +135,6 @@ public class AnyCommand {
return rawCommand; return rawCommand;
} }
} catch (Throwable e) { } catch (Throwable e) {
FileLog.MAIN.log(e);
return rawCommand; return rawCommand;
} }
} }