Skip to content

Commit dac2c6a

Browse files
committed
Log the creation of actually used FileSystemVoids #42
Signed-off-by: Mārtiņš Avots <martins.avots@splitcells.net>
1 parent a7bcbf4 commit dac2c6a

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

projects/net.splitcells.dem.api/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Changelog
66
## [Unreleased]
77
### Major Changes
8+
* **2025-11-24\#37** Log the creation of actually used FileSystemVoids.
89
* **2025-10-20\#37** Rename `List#forEachIndex` to `List#forEachIndexed`.
910
* **2025-07-21\#37** Rename CsvDocument to CsvPrinter, as it is otherwise misleading and create a new CsvDocument class,
1011
that supports reading CSV contents for now.

projects/net.splitcells.dem.api/src/main/java/net/splitcells/dem/lang/tree/Tree.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ default void requireEqualsTo(Tree other) {
357357

358358
default Tree withPath(Tree... path) {
359359
var current = this;
360-
for (int i = 0 ; i < path.length ; ++i) {
360+
for (int i = 0; i < path.length; ++i) {
361361
final var next = path[i];
362362
current.withChild(next);
363363
current = next;
@@ -1190,7 +1190,11 @@ default Merger merge(Merger merger) {
11901190
}
11911191

11921192
default Tree with(Throwable throwable) {
1193-
final var throwableTree = tree("throwable")
1193+
return with("throwable", throwable);
1194+
}
1195+
1196+
default Tree with(String description, Throwable throwable) {
1197+
final var throwableTree = tree(description)
11941198
.withChild(tree("message").withChild(tree(throwable.getMessage())))
11951199
.withChild(tree("stack-trace").withChild(tree(throwableToString(throwable))));
11961200
return withChild(throwableTree);

projects/net.splitcells.dem.api/src/main/java/net/splitcells/dem/resource/FileSystemVoid.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import static net.splitcells.dem.resource.communication.log.Logs.logs;
2323
import static net.splitcells.dem.utils.BinaryUtils.emptyByteArray;
24+
import static net.splitcells.dem.utils.ExecutionException.execException;
2425
import static net.splitcells.dem.utils.NotImplementedYet.notImplementedYet;
2526

2627
/**
@@ -33,14 +34,15 @@ public static FileSystem fileSystemVoid() {
3334
}
3435

3536
private boolean isUsageWarned = false;
37+
private Throwable creation = execException();
3638

3739
private FileSystemVoid() {
3840

3941
}
4042

4143
private void warnUsage() {
4244
if (!isUsageWarned) {
43-
logs().warnUnimplementedPart(FileSystemVoid.class);
45+
logs().warnUnimplementedPart(FileSystemVoid.class, creation);
4446
isUsageWarned = true;
4547
}
4648
}

projects/net.splitcells.dem.api/src/main/java/net/splitcells/dem/resource/communication/log/Log.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ default Log warnUnimplementedPart(Class<?> clazz) {
7272
return this;
7373
}
7474

75+
/**
76+
*
77+
* @param clazz
78+
* @param creation Provides the stacktrace, that points to the constructor call of {@code clazz}.
79+
* @return
80+
*/
81+
default Log warnUnimplementedPart(Class<?> clazz, Throwable creation) {
82+
logs().append(tree("Unimplemented program part for class " + clazz + " at")
83+
.with("creation", creation)
84+
.with("current-execution", execException("current-execution"))
85+
, LogLevel.WARNING);
86+
return this;
87+
}
88+
7589
default Log warnUnimplementedPart() {
7690
logs().append("Unimplemented program part at:\n"
7791
+ throwableToString(ExecutionException.execException("no-message"))

0 commit comments

Comments
 (0)