Skip to content

Commit

Permalink
Clean up logging
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Jul 16, 2024
1 parent e47228e commit e1ba285
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
try {
super.launch(builder);
} catch (CoreException e) {
String msg = "Exception when launching readapt: " + String.join(" ", readaptCommand);
LogHelper.error(msg);
LogHelper.error("Exception when launching readapt: " + String.join(" ", readaptCommand), e);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pierre-Yves B. and others.
* Copyright (c) 2019-2024 Pierre-Yves B. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -51,7 +51,7 @@ protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
} else {
LogHelper.error("Unexpected exit value " + exitValue + " from command " + commandString
+ System.lineSeparator() + "Error details:" + System.lineSeparator() + error.get(), null);
+ System.lineSeparator() + "Error details:" + System.lineSeparator() + error.get());
}
} catch (IOException | ExecutionException e) {
LogHelper.error("Exception whilst running command " + commandString, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.concurrent.CompletableFuture;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
Expand Down Expand Up @@ -38,14 +37,12 @@ public static Job createJob(ILaunch launch, String command, File workingDirector
}
int exc = process.exitValue();
if (exc != 0) {
String msg = String.format("Process exited non-zero (%d): %s ", exc, command);
LogHelper.error(msg);
LogHelper.error(String.format("Process exited non-zero (%d): %s ", exc, command));
}
});
DebugPlugin.newProcess(launch, process, command);
} catch (CoreException e) {
// CoreException from exec
LogHelper.log(IStatus.ERROR, "Exception when launching process: " + command, e);
LogHelper.error("Exception when launching process: " + command, e);
return;
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pierre-Yves B. and others.
* Copyright (c) 2019-2024 Pierre-Yves B. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -25,28 +25,20 @@ public class LogHelper {
private static final String LOGNAME = BUNDLE.getSymbolicName();
private static final ILog LOGGER = Platform.getLog(BUNDLE);

public static void log(int severity, String message) {
LOGGER.log(new Status(severity, LOGNAME, message));
}

public static void log(int severity, String message, Throwable throwable) {
LOGGER.log(new Status(severity, LOGNAME, message, throwable));
}

public static void info(String message) {
log(IStatus.INFO, message);
LOGGER.log(new Status(IStatus.INFO, LOGNAME, message));
}

public static void error(String message, Throwable exception) {
log(IStatus.ERROR, message, exception);
LOGGER.log(new Status(IStatus.ERROR, LOGNAME, message, exception));
}

public static void error(String message) {
log(IStatus.ERROR, message);
LOGGER.log(new Status(IStatus.ERROR, LOGNAME, message));
}

public static void cancelled(String message) {
log(IStatus.CANCEL, message);
LOGGER.log(new Status(IStatus.CANCEL, LOGNAME, message));
}

private LogHelper() {
Expand Down

0 comments on commit e1ba285

Please sign in to comment.