Skip to content

Commit c935dc9

Browse files
committed
Improve logging in config chain
1 parent df0825e commit c935dc9

8 files changed

+53
-22
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerJvmClassPathConfigurer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.github.ascopes.jct.compilers.JctCompiler;
1919
import io.github.ascopes.jct.filemanagers.JctFileManager;
2020
import io.github.ascopes.jct.utils.SpecialLocationUtils;
21+
import io.github.ascopes.jct.utils.StringUtils;
2122
import io.github.ascopes.jct.workspaces.impl.WrappingDirectoryImpl;
2223
import javax.tools.StandardLocation;
2324
import org.apiguardian.api.API;
@@ -57,7 +58,12 @@ public JctFileManager configure(JctFileManager fileManager) {
5758
SpecialLocationUtils
5859
.currentClassPathLocations()
5960
.stream()
60-
.peek(loc -> LOGGER.trace("Adding {} to file manager classpath (inherited from JVM)", loc))
61+
.peek(loc -> LOGGER
62+
.atTrace()
63+
.setMessage("Adding {} ({}) to file manager class path (inherited from JVM))")
64+
.addArgument(() -> StringUtils.quoted(loc.toAbsolutePath()))
65+
.addArgument(() -> StringUtils.quoted(loc.toUri()))
66+
.log())
6167
.map(WrappingDirectoryImpl::new)
6268
.forEach(dir -> fileManager.addPath(StandardLocation.CLASS_PATH, dir));
6369

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerJvmClassPathModuleConfigurer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.github.ascopes.jct.compilers.JctCompiler;
1919
import io.github.ascopes.jct.filemanagers.JctFileManager;
2020
import io.github.ascopes.jct.utils.SpecialLocationUtils;
21+
import io.github.ascopes.jct.utils.StringUtils;
2122
import io.github.ascopes.jct.workspaces.impl.WrappingDirectoryImpl;
2223
import javax.tools.StandardLocation;
2324
import org.apiguardian.api.API;
@@ -63,8 +64,12 @@ public JctFileManager configure(JctFileManager fileManager) {
6364
SpecialLocationUtils
6465
.currentClassPathLocations()
6566
.stream()
66-
.peek(
67-
loc -> LOGGER.trace("Adding {} to file manager module path (inherited from JVM)", loc))
67+
.peek(loc -> LOGGER
68+
.atTrace()
69+
.setMessage("Adding {} ({}) to file manager module path (inherited from JVM))")
70+
.addArgument(() -> StringUtils.quoted(loc.toAbsolutePath()))
71+
.addArgument(() -> StringUtils.quoted(loc.toUri()))
72+
.log())
6873
.map(WrappingDirectoryImpl::new)
6974
// File manager will pull out the actual modules automatically.
7075
.forEach(dir -> fileManager.addPath(StandardLocation.MODULE_PATH, dir));

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerJvmModulePathConfigurer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.github.ascopes.jct.compilers.JctCompiler;
1919
import io.github.ascopes.jct.filemanagers.JctFileManager;
2020
import io.github.ascopes.jct.utils.SpecialLocationUtils;
21+
import io.github.ascopes.jct.utils.StringUtils;
2122
import io.github.ascopes.jct.workspaces.impl.WrappingDirectoryImpl;
2223
import javax.tools.StandardLocation;
2324
import org.apiguardian.api.API;
@@ -58,7 +59,12 @@ public JctFileManager configure(JctFileManager fileManager) {
5859
SpecialLocationUtils
5960
.currentModulePathLocations()
6061
.stream()
61-
.peek(loc -> LOGGER.trace("Adding {} to file manager modulepath (inherited from JVM)", loc))
62+
.peek(loc -> LOGGER
63+
.atTrace()
64+
.setMessage("Adding {} ({}) to file manager module path (inherited from JVM))")
65+
.addArgument(() -> StringUtils.quoted(loc.toAbsolutePath()))
66+
.addArgument(() -> StringUtils.quoted(loc.toUri()))
67+
.log())
6268
.map(WrappingDirectoryImpl::new)
6369
.forEach(dir -> {
6470
// Since we do not know if the code being compiled will use modules or not just yet,

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerJvmPlatformClassPathConfigurer.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.github.ascopes.jct.compilers.JctCompiler;
1919
import io.github.ascopes.jct.filemanagers.JctFileManager;
2020
import io.github.ascopes.jct.utils.SpecialLocationUtils;
21+
import io.github.ascopes.jct.utils.StringUtils;
2122
import io.github.ascopes.jct.workspaces.impl.WrappingDirectoryImpl;
2223
import javax.tools.StandardLocation;
2324
import org.apiguardian.api.API;
@@ -64,9 +65,12 @@ public JctFileManager configure(JctFileManager fileManager) {
6465
SpecialLocationUtils
6566
.currentPlatformClassPathLocations()
6667
.stream()
67-
.peek(loc -> LOGGER.trace(
68-
"Adding {} to file manager platform classpath (inherited from JVM)", loc
69-
))
68+
.peek(loc -> LOGGER
69+
.atTrace()
70+
.setMessage("Adding {} ({}) to file manager platform class path (inherited from JVM))")
71+
.addArgument(() -> StringUtils.quoted(loc.toAbsolutePath()))
72+
.addArgument(() -> StringUtils.quoted(loc.toUri()))
73+
.log())
7074
.map(WrappingDirectoryImpl::new)
7175
.forEach(dir -> fileManager.addPath(StandardLocation.PLATFORM_CLASS_PATH, dir));
7276

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerJvmSystemModulesConfigurer.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.github.ascopes.jct.compilers.JctCompiler;
1919
import io.github.ascopes.jct.filemanagers.JctFileManager;
2020
import io.github.ascopes.jct.utils.SpecialLocationUtils;
21+
import io.github.ascopes.jct.utils.StringUtils;
2122
import io.github.ascopes.jct.workspaces.impl.WrappingDirectoryImpl;
2223
import javax.tools.StandardLocation;
2324
import org.apiguardian.api.API;
@@ -57,9 +58,12 @@ public JctFileManager configure(JctFileManager fileManager) {
5758
SpecialLocationUtils
5859
.javaRuntimeLocations()
5960
.stream()
60-
.peek(loc -> LOGGER.trace(
61-
"Adding {} to the system modules path (inherited from JVM)", loc
62-
))
61+
.peek(loc -> LOGGER
62+
.atTrace()
63+
.setMessage("Adding {} ({}) to file manager system modules path (inherited from JVM))")
64+
.addArgument(() -> StringUtils.quoted(loc.toAbsolutePath()))
65+
.addArgument(() -> StringUtils.quoted(loc.toUri()))
66+
.log())
6367
.map(WrappingDirectoryImpl::new)
6468
.forEach(dir -> fileManager.addPath(StandardLocation.SYSTEM_MODULES, dir));
6569

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerLoggingProxyConfigurer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public JctFileManager configure(JctFileManager fileManager) {
5454

5555
switch (compiler.getFileManagerLoggingMode()) {
5656
case STACKTRACES:
57-
LOGGER.trace("Decorating file manager {} in a logging proxy with stacktraces", fileManager);
57+
LOGGER.trace("Decorating file manager {} in a logger proxy with stack traces", fileManager);
5858
return LoggingFileManagerProxy.wrap(fileManager, true);
5959
case ENABLED:
60-
LOGGER.trace("Decorating file manager {} in a logging proxy", fileManager);
60+
LOGGER.trace("Decorating file manager {} in a logger proxy", fileManager);
6161
return LoggingFileManagerProxy.wrap(fileManager, false);
6262
default:
63-
throw new IllegalStateException("Cannot configure logging proxy");
63+
throw new IllegalStateException("Cannot configure logger proxy");
6464
}
6565
}
6666

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerRequiredLocationsConfigurer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static java.util.function.Predicate.not;
1919

2020
import io.github.ascopes.jct.filemanagers.JctFileManager;
21+
import io.github.ascopes.jct.utils.StringUtils;
2122
import io.github.ascopes.jct.workspaces.Workspace;
2223
import java.util.Set;
2324
import javax.tools.StandardLocation;
@@ -51,7 +52,7 @@ public final class JctFileManagerRequiredLocationsConfigurer implements JctFileM
5152
StandardLocation.CLASS_OUTPUT,
5253
// We need to provide a header output path in case header generation is enabled at any stage.
5354
// I might make this disabled by default in the future if there is too much overhead from
54-
// doing this by default.
55+
// doing this.
5556
StandardLocation.NATIVE_HEADER_OUTPUT
5657
);
5758

@@ -73,13 +74,12 @@ public JctFileManager configure(JctFileManager fileManager) {
7374
REQUIRED_LOCATIONS
7475
.stream()
7576
.filter(not(fileManager::hasLocation))
76-
.forEach(location -> {
77-
LOGGER.trace(
78-
"Required location {} does not exist, so will be created in the workspace",
79-
location
80-
);
81-
fileManager.addPath(location, workspace.createPackage(location));
82-
});
77+
.peek(location -> LOGGER.atTrace()
78+
.setMessage("Required location {} does not exist, so will be created in the workspace")
79+
.addArgument(() -> StringUtils.quoted(location.getName()))
80+
.log())
81+
.forEach(location -> fileManager.addPath(location, workspace.createPackage(location)));
82+
8383
return fileManager;
8484
}
8585
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/filemanagers/config/JctFileManagerWorkspaceConfigurer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.github.ascopes.jct.filemanagers.config;
1717

1818
import io.github.ascopes.jct.filemanagers.JctFileManager;
19+
import io.github.ascopes.jct.utils.StringUtils;
1920
import io.github.ascopes.jct.workspaces.Workspace;
2021
import org.apiguardian.api.API;
2122
import org.apiguardian.api.API.Status;
@@ -47,8 +48,13 @@ public JctFileManagerWorkspaceConfigurer(Workspace workspace) {
4748

4849
@Override
4950
public JctFileManager configure(JctFileManager fileManager) {
51+
LOGGER.debug("Configuring file manager with user-provided paths");
5052
var paths = workspace.getAllPaths();
51-
LOGGER.debug("Copying user-defined paths from workspace ({})", paths);
53+
LOGGER
54+
.atTrace()
55+
.setMessage("Copying user-defined paths from workspace into file manager ({})")
56+
.addArgument(() -> StringUtils.quoted(paths))
57+
.log();
5258
workspace.getAllPaths().forEach(fileManager::addPaths);
5359
return fileManager;
5460
}

0 commit comments

Comments
 (0)