Skip to content

Commit 519b2ca

Browse files
uhoefelluhenry
andauthored
Refine logging (#27)
* bump JUnit version * Refine logging Explicitly state what has been loaded, and show failures only upon a sufficient logging level, as they should not hamper correct operation * Use UncheckedIOException instead of RuntimeException for caught IOE * Add the throwable to the fine grained logging message Should help with #20 * Fix logging for throwable info * Fix whitespace * Simplify dumping which blas/lapack/arpack we are using --------- Co-authored-by: Ludovic Henry <[email protected]>
1 parent 35d12f3 commit 519b2ca

File tree

9 files changed

+29
-17
lines changed

9 files changed

+29
-17
lines changed

arpack/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ information or have any questions.
4242
<packaging>jar</packaging>
4343

4444
<properties>
45-
<junit.version>5.8.2</junit.version>
45+
<junit.version>5.13.4</junit.version>
4646
<automatic.module.name>dev.ludovic.netlib.arpack</automatic.module.name>
4747
</properties>
4848

arpack/src/main/java/dev/ludovic/netlib/arpack/InstanceBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package dev.ludovic.netlib.arpack;
2727

28+
import java.util.logging.Level;
2829
import java.util.logging.Logger;
2930

3031
final class InstanceBuilder {
@@ -39,6 +40,8 @@ final class InstanceBuilder {
3940
nativeArpack = initializeNative();
4041
javaArpack = initializeJava();
4142
arpack = nativeArpack != null ? nativeArpack : javaArpack;
43+
44+
log.info("Using " + arpack.getClass().getName());
4245
}
4346

4447
public static ARPACK arpack() {
@@ -49,7 +52,7 @@ private static NativeARPACK initializeNative() {
4952
try {
5053
return JNIARPACK.getInstance();
5154
} catch (Throwable t) {
52-
log.warning("Failed to load implementation from:" + JNIARPACK.class.getName());
55+
log.log(Level.FINE, "Failed to load implementation from:" + JNIARPACK.class.getName(), t);
5356
return null;
5457
}
5558
}

arpack/src/main/java/dev/ludovic/netlib/arpack/JNIARPACK.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
package dev.ludovic.netlib.arpack;
2727

28-
import java.io.InputStream;
2928
import java.io.IOException;
29+
import java.io.InputStream;
30+
import java.io.UncheckedIOException;
3031
import java.nio.file.Files;
3132
import java.nio.file.Path;
3233
import java.nio.file.StandardCopyOption;
@@ -55,7 +56,7 @@ protected JNIARPACK() {
5556
StandardCopyOption.REPLACE_EXISTING);
5657
temp.toFile().deleteOnExit();
5758
} catch (IOException e) {
58-
throw new RuntimeException("Unable to load native implementation", e);
59+
throw new UncheckedIOException("Unable to load native implementation", e);
5960
}
6061

6162
System.load(temp.toString());

blas/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ information or have any questions.
4242
<packaging>jar</packaging>
4343

4444
<properties>
45-
<junit.version>5.8.2</junit.version>
45+
<junit.version>5.13.4</junit.version>
4646
<automatic.module.name>dev.ludovic.netlib.blas</automatic.module.name>
4747
</properties>
4848

blas/src/main/java/dev/ludovic/netlib/blas/InstanceBuilder.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package dev.ludovic.netlib.blas;
2727

28+
import java.util.logging.Level;
2829
import java.util.logging.Logger;
2930

3031
final class InstanceBuilder {
@@ -39,6 +40,8 @@ final class InstanceBuilder {
3940
nativeBlas = initializeNative();
4041
javaBlas = initializeJava();
4142
blas = nativeBlas != null ? nativeBlas : javaBlas;
43+
44+
log.info("Using " + blas.getClass().getName());
4245
}
4346

4447
public static BLAS blas() {
@@ -49,7 +52,7 @@ private static NativeBLAS initializeNative() {
4952
try {
5053
return JNIBLAS.getInstance();
5154
} catch (Throwable t) {
52-
log.warning("Failed to load implementation from:" + JNIBLAS.class.getName());
55+
log.log(Level.FINE, "Failed to load implementation from:" + JNIBLAS.class.getName(), t);
5356
return null;
5457
}
5558
}
@@ -69,16 +72,15 @@ private static JavaBLAS initializeJava() {
6972
log.finest("trying to return java 16 instance");
7073
return VectorBLAS.getInstance();
7174
} catch (Throwable t) {
72-
log.warning("Failed to load implementation from:" + VectorBLAS.class.getName());
75+
log.log(Level.FINE, "Failed to load implementation from:" + VectorBLAS.class.getName(), t);
7376
}
7477
}
7578
if (major >= 11) {
7679
log.finest("return java 11 instance");
7780
return Java11BLAS.getInstance();
78-
} else {
79-
log.finest("return java 8 instance");
80-
return Java8BLAS.getInstance();
8181
}
82+
log.finest("return java 8 instance");
83+
return Java8BLAS.getInstance();
8284
}
8385

8486
public static JavaBLAS javaBlas() {

blas/src/main/java/dev/ludovic/netlib/blas/JNIBLAS.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
package dev.ludovic.netlib.blas;
2727

28-
import java.io.InputStream;
2928
import java.io.IOException;
29+
import java.io.InputStream;
30+
import java.io.UncheckedIOException;
3031
import java.nio.file.Files;
3132
import java.nio.file.Path;
3233
import java.nio.file.StandardCopyOption;
@@ -55,7 +56,7 @@ protected JNIBLAS() {
5556
StandardCopyOption.REPLACE_EXISTING);
5657
temp.toFile().deleteOnExit();
5758
} catch (IOException e) {
58-
throw new RuntimeException("Unable to load native implementation", e);
59+
throw new UncheckedIOException("Unable to load native implementation", e);
5960
}
6061

6162
System.load(temp.toString());

lapack/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ information or have any questions.
4242
<packaging>jar</packaging>
4343

4444
<properties>
45-
<junit.version>5.8.2</junit.version>
45+
<junit.version>5.13.4</junit.version>
4646
<automatic.module.name>dev.ludovic.netlib.lapack</automatic.module.name>
4747
</properties>
4848

lapack/src/main/java/dev/ludovic/netlib/lapack/InstanceBuilder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package dev.ludovic.netlib.lapack;
2727

28+
import java.util.logging.Level;
2829
import java.util.logging.Logger;
2930

3031
final class InstanceBuilder {
@@ -39,6 +40,8 @@ final class InstanceBuilder {
3940
nativeLapack = initializeNative();
4041
javaLapack = initializeJava();
4142
lapack = nativeLapack != null ? nativeLapack : javaLapack;
43+
44+
log.info("Using " + lapack.getClass().getName());
4245
}
4346

4447
public static LAPACK lapack() {
@@ -49,14 +52,14 @@ private static NativeLAPACK initializeNative() {
4952
try {
5053
return JNILAPACK.getInstance();
5154
} catch (Throwable t) {
52-
log.warning("Failed to load implementation from:" + JNILAPACK.class.getName());
55+
log.log(Level.FINE, "Failed to load implementation from:" + JNILAPACK.class.getName(), t);
5356
return null;
5457
}
5558
}
5659

5760
public static NativeLAPACK nativeLapack() {
5861
if (nativeLapack == null) {
59-
throw new RuntimeException("Unable to load native implementation");
62+
throw new RuntimeException("Unable to load native LAPACK implementation");
6063
}
6164
return nativeLapack;
6265
}

lapack/src/main/java/dev/ludovic/netlib/lapack/JNILAPACK.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package dev.ludovic.netlib.lapack;
2727

2828
import java.io.InputStream;
29+
import java.io.UncheckedIOException;
2930
import java.io.IOException;
3031
import java.nio.file.Files;
3132
import java.nio.file.Path;
@@ -55,10 +56,11 @@ protected JNILAPACK() {
5556
StandardCopyOption.REPLACE_EXISTING);
5657
temp.toFile().deleteOnExit();
5758
} catch (IOException e) {
58-
throw new RuntimeException("Unable to load native implementation", e);
59+
throw new UncheckedIOException("Unable to load native implementation", e);
5960
}
6061

61-
System.load(temp.toString());}
62+
System.load(temp.toString());
63+
}
6264

6365
public static NativeLAPACK getInstance() {
6466
return instance;

0 commit comments

Comments
 (0)