Skip to content

Commit 22516b6

Browse files
authored
Merge pull request #1458 from lesserwhirls/nce
Improve netcdf4 logging
2 parents b4d8972 + 978d571 commit 22516b6

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

netcdf4/src/main/java/ucar/nc2/ffi/netcdf/NetcdfClibrary.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
/** Static methods to load the netcdf C library. */
1515
public class NetcdfClibrary {
1616
private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(NetcdfClibrary.class);
17-
private static org.slf4j.Logger startupLog = org.slf4j.LoggerFactory.getLogger("serverStartup");
1817

1918
private static final String JNA_PATH = "jna.library.path";
2019
private static final String JNA_PATH_ENV = "JNA_PATH"; // environment var
@@ -107,7 +106,7 @@ public static synchronized int setLogLevel(int level) {
107106
if (nc4 != null) {
108107
try {
109108
oldlevel = nc4.nc_set_log_level(log_level);
110-
startupLog.info(String.format("NetcdfLoader: set log level: old=%d new=%d", oldlevel, log_level));
109+
log.info(String.format("NetcdfLoader: set log level: old=%d new=%d", oldlevel, log_level));
111110
} catch (UnsatisfiedLinkError e) {
112111
// ignore
113112
}
@@ -127,13 +126,14 @@ private static Nc4prototypes load() {
127126
// Make the library synchronized
128127
// nc4 = (Nc4prototypes) Native.synchronizedLibrary(nc4);
129128
nc4 = new Nc4wrapper(nc4);
130-
startupLog.info("Nc4Iosp: NetCDF-4 C library loaded (jna_path='{}', libname='{}' version='{}').", jnaPath,
131-
libName, getVersion());
132-
startupLog.debug("Netcdf nc_inq_libvers='{}' isProtected={}", nc4.nc_inq_libvers(), Native.isProtected());
129+
log.info("Nc4Iosp: NetCDF-4 C library loaded (jna_path='{}', libname='{}' version='{}').", jnaPath, libName,
130+
getVersion());
131+
log.debug("Netcdf nc_inq_libvers='{}' isProtected={}", nc4.nc_inq_libvers(), Native.isProtected());
133132
} catch (Throwable t) {
134133
String message =
135134
String.format("Nc4Iosp: NetCDF-4 C library not present (jna_path='%s', libname='%s').", jnaPath, libName);
136-
startupLog.warn(message, t);
135+
log.warn(message);
136+
log.debug("details: ", t);
137137
}
138138
String slevel = Strings.emptyToNull(System.getProperty(JNA_LOG_LEVEL));
139139
if (slevel != null) {
@@ -144,13 +144,11 @@ private static Nc4prototypes load() {
144144
}
145145
}
146146
try {
147-
int oldlevel = setLogLevel(log_level);
148-
startupLog.info(String.format("Nc4Iosp: set log level: old=%d new=%d", oldlevel, log_level));
147+
setLogLevel(log_level);
149148
} catch (Throwable t) {
150149
String message = String.format("Nc4Iosp: could not set log level (level=%d jna_path='%s', libname='%s').",
151150
log_level, jnaPath, libName);
152-
startupLog.warn("Nc4Iosp: " + t.getMessage());
153-
startupLog.warn(message);
151+
log.debug("Nc4Iosp: " + t.getMessage());
154152
}
155153
}
156154
return nc4;

netcdf4/src/main/java/ucar/nc2/jni/netcdf/Nc4Iosp.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
@Deprecated
5050
public class Nc4Iosp extends AbstractIOServiceProvider implements IOServiceProviderWriter {
5151
private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Nc4Iosp.class);
52-
private static org.slf4j.Logger startupLog = org.slf4j.LoggerFactory.getLogger("serverStartup");
5352

5453
public static final boolean DEBUG = false;
5554

0 commit comments

Comments
 (0)