diff --git a/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioDContext.java b/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioDContext.java index 52522998..959a55a1 100644 --- a/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioDContext.java +++ b/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/internal/GpioDContext.java @@ -70,7 +70,7 @@ public synchronized void initialize() { throw new IllegalStateException("Couldn't identify gpiochip!"); this.gpioChip = found; - logger.info("Using chip " + this.gpioChip.getName() + " " + this.gpioChip.getLabel()); + logger.info("Using chip {} {}", this.gpioChip.getName(), this.gpioChip.getLabel()); } public synchronized GpioLine getOrOpenLine(int offset) { diff --git a/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java b/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java index 86e90d0c..4eeccea8 100644 --- a/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java +++ b/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java @@ -61,7 +61,7 @@ public static synchronized void load(String fileName, String libName) { // first, make sure that this library has not already been previously loaded if (loadedLibraries.contains(fileName)) { - logger.warn("Library [" + fileName + "] has already been loaded; no need to load again."); + logger.warn("Library [{}] has already been loaded; no need to load again.", fileName); return; } @@ -74,7 +74,7 @@ public static synchronized void load(String fileName, String libName) { // if the overriding library path is set to "system", then attempt to use the system resolved library paths if (libpath.equalsIgnoreCase("system")) { - logger.debug("Attempting to load library using {pi4j.library.path} system resolved library name: [" + libName + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} system resolved library name: [{}]", libName); try { // load library from JVM system library path; based on library name System.loadLibrary(libName); @@ -100,7 +100,7 @@ else if (libpath.equalsIgnoreCase("local")) { } // build path based on lib directory and lib filename String path = Paths.get(libpath, fileName).toString(); - logger.debug("Attempting to load library using {pi4j.library.path} defined path: [" + path + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} defined path: [{}]", path); try { // load library from local path of this JAR file System.load(path); @@ -119,7 +119,7 @@ else if (libpath.equalsIgnoreCase("local")) { else { // build path based on lib directory and lib filename String path = Paths.get(libpath, fileName).toString(); - logger.debug("Attempting to load library using {pi4j.library.path} defined path: [" + path + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} defined path: [{}]", path); try { // load library from user defined absolute path provided via pi4j.library.path} System.load(path); @@ -174,12 +174,12 @@ else if (libpath.equalsIgnoreCase("local")) { // include the CPU architecture in the embedded path String path = "/lib/" + osArch + "/" + libName + "/" + fileName; - logger.debug("Attempting to load library [" + fileName + "] using path: [" + path + "]"); + logger.debug("Attempting to load library [{}] using path: [{}]", fileName, path); try { loadLibraryFromClasspath(path); - logger.debug("Library [" + fileName + "] loaded successfully using embedded resource file: [" + path + "]"); + logger.debug("Library [{}] loaded successfully using embedded resource file: [{}]", fileName, path); } catch (UnsatisfiedLinkError e) { - logger.error("Unable to load [" + fileName + "] using path: [" + path + "]", e); + logger.error("Unable to load [{}] using path: [{}]", fileName, path, e); String exceptMessage; // no guarantee the except pertains to ELF miss-match so check MSG content if (e.getMessage().contains("wrong ELF class")) { @@ -199,7 +199,7 @@ else if (libpath.equalsIgnoreCase("local")) { } throw new UnsatisfiedLinkError(exceptMessage); } catch (Exception e) { - logger.error("Unable to load [" + fileName + "] using path: [" + path + "]", e); + logger.error("Unable to load [{}] using path: [{}]", fileName, path, e); throw new UnsatisfiedLinkError("Pi4J was unable to extract and load the native library [" + path + "] from the embedded resources inside this JAR [" + NativeLibraryLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath() + diff --git a/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java b/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java index f1f39d0d..4cb23e6d 100644 --- a/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java +++ b/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java @@ -61,7 +61,7 @@ public static synchronized void load(String fileName, String libName) { // first, make sure that this library has not already been previously loaded if (loadedLibraries.contains(fileName)) { - logger.warn("Library [" + fileName + "] has already been loaded; no need to load again."); + logger.warn("Library [{}] has already been loaded; no need to load again.", fileName); return; } @@ -74,7 +74,7 @@ public static synchronized void load(String fileName, String libName) { // if the overriding library path is set to "system", then attempt to use the system resolved library paths if (libpath.equalsIgnoreCase("system")) { - logger.debug("Attempting to load library using {pi4j.library.path} system resolved library name: [" + libName + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} system resolved library name: [{}]", libName); try { // load library from JVM system library path; based on library name System.loadLibrary(libName); @@ -100,7 +100,7 @@ else if (libpath.equalsIgnoreCase("local")) { } // build path based on lib directory and lib filename String path = Paths.get(libpath, fileName).toString(); - logger.debug("Attempting to load library using {pi4j.library.path} defined path: [" + path + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} defined path: [{}]", path); try { // load library from local path of this JAR file System.load(path); @@ -119,7 +119,7 @@ else if (libpath.equalsIgnoreCase("local")) { else { // build path based on lib directory and lib filename String path = Paths.get(libpath, fileName).toString(); - logger.debug("Attempting to load library using {pi4j.library.path} defined path: [" + path + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} defined path: [{}]", path); try { // load library from user defined absolute path provided via pi4j.library.path} System.load(path); @@ -174,12 +174,12 @@ else if (libpath.equalsIgnoreCase("local")) { // include the CPU architecture in the embedded path String path = "/lib/" + osArch + "/" + libName + "/" + fileName; - logger.debug("Attempting to load library [" + fileName + "] using path: [" + path + "]"); + logger.debug("Attempting to load library [{}] using path: [{}]", fileName, path); try { loadLibraryFromClasspath(path); - logger.debug("Library [" + fileName + "] loaded successfully using embedded resource file: [" + path + "]"); + logger.debug("Library [{}] loaded successfully using embedded resource file: [{}]", fileName, path); } catch (UnsatisfiedLinkError e) { - logger.error("Unable to load [" + fileName + "] using path: [" + path + "]", e); + logger.error("Unable to load [{}] using path: [{}]", fileName, path, e); String exceptMessage; // no guarantee the except pertains to ELF miss-match so check MSG content if (e.getMessage().contains("wrong ELF class")) { @@ -199,7 +199,7 @@ else if (libpath.equalsIgnoreCase("local")) { } throw new UnsatisfiedLinkError(exceptMessage); } catch (Exception e) { - logger.error("Unable to load [" + fileName + "] using path: [" + path + "]", e); + logger.error("Unable to load [{}] using path: [{}]", fileName, path, e); throw new UnsatisfiedLinkError("Pi4J was unable to extract and load the native library [" + path + "] from the embedded resources inside this JAR [" + NativeLibraryLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath() + diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java index 43d748bd..ff8ca765 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java @@ -260,7 +260,7 @@ protected void validateResult(long value) { protected void validateResult(long value, boolean throwException) { if(value < 0) { PiGpioError err = PiGpioError.from(value); - logger.warn("PIGPIO ERROR: " + err.name() + "; " + err.message()); + logger.warn("PIGPIO ERROR: {}; {}", err.name(), err.message()); if(throwException) { throw new PiGpioException("PIGPIO ERROR: " + err.name() + "; " + err.message()); } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java index d556ffb3..ff0ec5d0 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java @@ -207,13 +207,13 @@ protected PiGpioPacket sendPacket(PiGpioPacket tx, Socket sck) { var out = sck.getOutputStream(); // transmit packet - logger.trace("[TX] -> " + tx.toString()); + logger.trace("[TX] -> {}", tx.toString()); out.write(PiGpioPacket.encode(tx)); out.flush(); // read receive packet PiGpioPacket rx = PiGpioPacket.decode(in); - logger.trace("[RX] <- " + rx.toString()); + logger.trace("[RX] <- {}", rx.toString()); return rx; } catch (SocketException se) { // socket is no longer connected diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/Init.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/Init.java index 996bc76b..45f51ac9 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/Init.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/Init.java @@ -65,12 +65,12 @@ public static void main(String[] args) { logger.info("-----------------------------------------------------"); int init = piGpio.gpioInitialise(); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); } else { logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); } - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + Long.toHexString(piGpio.gpioHardwareRevision())); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", Long.toHexString(piGpio.gpioHardwareRevision())); piGpio.gpioTerminate(); logger.info("PIGPIO TERMINATED"); logger.info("-----------------------------------------------------"); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRaw.java index 7fc0538a..1a609ffc 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRaw.java @@ -61,11 +61,11 @@ public static void main(String[] args) { logger.info("Pi4J Library :: PIGPIO JNI (Raw) Wrapper Library"); logger.info("-----------------------------------------------------"); logger.info("-----------------------------------------------------"); - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + Integer.toHexString(PIGPIO.gpioHardwareRevision())); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", Integer.toHexString(PIGPIO.gpioHardwareRevision())); int init = PIGPIO.gpioInitialise(); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); } else { logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); PIGPIO.gpioTerminate(); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRemote.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRemote.java index e40a8103..e7af3150 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRemote.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/InitRemote.java @@ -70,12 +70,12 @@ public static void main(String[] args) { logger.info("-----------------------------------------------------"); int init = piGpio.gpioInitialise(); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); } else { logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); } - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + Long.toHexString(piGpio.gpioHardwareRevision())); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", Long.toHexString(piGpio.gpioHardwareRevision())); piGpio.gpioTerminate(); logger.info("PIGPIO TERMINATED"); logger.info("-----------------------------------------------------"); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java index d6903f5a..7cce5cbc 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java @@ -67,8 +67,8 @@ public static void main(String[] args) throws IOException { logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); logger.info("-----------------------------------------------------"); - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + piGpio.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", piGpio.gpioHardwareRevision()); piGpio.gpioSetMode(GPIO_PIN, PiGpioMode.INPUT); @@ -78,7 +78,7 @@ public static void main(String[] args) throws IOException { piGpio.addPinListener(GPIO_PIN, new PiGpioStateChangeListener() { @Override public void onChange(PiGpioStateChangeEvent event) { - logger.info("RECEIVED ALERT EVENT! " + event); + logger.info("RECEIVED ALERT EVENT! {}", event); throw new PiGpioException("TEST"); } }); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java index 97441b82..a9c5c41e 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java @@ -68,11 +68,11 @@ public static void main(String[] args) throws IOException { logger.info("Pi4J Library :: PIGPIO JNI (Raw) Wrapper Library"); logger.info("-----------------------------------------------------"); logger.info("-----------------------------------------------------"); - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + Integer.toHexString(PIGPIO.gpioHardwareRevision())); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", Integer.toHexString(PIGPIO.gpioHardwareRevision())); int init = PIGPIO.gpioInitialise(); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); } else { logger.info("-----------------------------------------------------"); logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); @@ -84,7 +84,7 @@ public static void main(String[] args) throws IOException { PIGPIO.gpioSetAlertFunc(GPIO_PIN, new PiGpioAlertCallback() { @Override public void call(int pin, int state, long tick) { - logger.info("RECEIVED ALERT EVENT! " + pin + " : " + state + " :" + tick); + logger.info("RECEIVED ALERT EVENT! {} : {} :{}", pin, state, tick); } }); @@ -98,7 +98,7 @@ public void call(int pin, int state, long tick) { PIGPIO.gpioSetAlertFuncEx(GPIO_PIN, new PiGpioAlertCallbackEx() { @Override public void call(int pin, int state, long tick, Object userdata) { - logger.info("RECEIVED ALERT EVENT! " + pin + " : " + state + " :" + tick + " : " + userdata); + logger.info("RECEIVED ALERT EVENT! {} : {} :{} : " + userdata, pin, state, tick); } }, testdata); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java index a03b5507..dd122e76 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java @@ -68,11 +68,11 @@ public static void main(String[] args) throws IOException { logger.info("Pi4J Library :: PIGPIO JNI (Raw) Wrapper Library"); logger.info("-----------------------------------------------------"); logger.info("-----------------------------------------------------"); - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + Integer.toHexString(PIGPIO.gpioHardwareRevision())); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", Integer.toHexString(PIGPIO.gpioHardwareRevision())); int init = PIGPIO.gpioInitialise(); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); } else { logger.info("-----------------------------------------------------"); logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); @@ -84,7 +84,7 @@ public static void main(String[] args) throws IOException { PIGPIO.gpioSetISRFunc(GPIO_PIN, new PiGpioIsrCallback() { @Override public void call(int pin, int state, long tick) { - logger.info("RECEIVED ISR EVENT! " + pin + " : " + state + " :" + tick); + logger.info("RECEIVED ISR EVENT! {} : {} :{}", pin, state, tick); } }); @@ -98,7 +98,7 @@ public void call(int pin, int state, long tick) { PIGPIO.gpioSetISRFuncEx(GPIO_PIN, new PiGpioIsrCallbackEx() { @Override public void call(int pin, int state, long tick, Object userdata) { - logger.info("RECEIVED ISR EVENT! " + pin + " : " + state + " :" + tick + " : " + userdata); + logger.info("RECEIVED ISR EVENT! {} : {} :{} : " + userdata, pin, state, tick); } }, testdata); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2C.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2C.java index d8f3820b..56cd51c8 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2C.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2C.java @@ -59,14 +59,14 @@ public static void main(String[] args) { piGpio.gpioInitialise(); logger.info("PIGPIO INITIALIZED"); - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + piGpio.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", piGpio.gpioHardwareRevision()); // open I2C channel/bus/device int handle = piGpio.i2cOpen(I2C_BUS, I2C_DEVICE); - logger.info("PIGPIO I2C OPEN : " + handle); + logger.info("PIGPIO I2C OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } @@ -81,26 +81,26 @@ public static void main(String[] args) { logger.info("[W/R BYTE]"); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = piGpio.i2cWriteByte(handle, (byte)b); if(result < 0) { - logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: SINGLE RAW BYTE result = piGpio.i2cReadByte(handle); if(result < 0) { - logger.error("\nERROR; I2C READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); int expected = b; int received = result; if(received != expected) { - logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -116,34 +116,33 @@ public static void main(String[] args) { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = piGpio.i2cWriteDevice(handle, writeBuffer); if(result < 0) { - logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: MULTI-BYTE byte[] readBuffer = new byte[len]; result = piGpio.i2cReadDevice(handle, readBuffer); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if(result < 0) { - logger.error("\nERROR; I2C READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if(result != len) { - logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } //validate data read back is same as written if(!Arrays.equals(writeBuffer, readBuffer)) { - logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(writeBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(writeBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRaw.java index 2f488e46..99269914 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRaw.java @@ -53,21 +53,21 @@ public class TestI2CRaw { * @param args an array of {@link String} objects. */ public static void main(String[] args) { - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + PIGPIO.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", PIGPIO.gpioHardwareRevision()); int init = PIGPIO.gpioInitialise(); - logger.info("PIGPIO INITIALIZE: " + init); + logger.info("PIGPIO INITIALIZE: {}", init); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); System.exit(init); } // open I2C channel/bus/device int handle = PIGPIO.i2cOpen(I2C_BUS, I2C_DEVICE, 0); - logger.info("PIGPIO I2C OPEN : " + handle); + logger.info("PIGPIO I2C OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } @@ -82,26 +82,26 @@ public static void main(String[] args) { logger.info("[W/R BYTE]"); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = PIGPIO.i2cWriteByte(handle, (byte)b); if(result < 0) { - logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: SINGLE RAW BYTE result = PIGPIO.i2cReadByte(handle); if(result < 0) { - logger.error("\nERROR; I2C READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); int expected = b; int received = result; if(received != expected) { - logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -117,34 +117,33 @@ public static void main(String[] args) { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = PIGPIO.i2cWriteDevice(handle, writeBuffer, len); if(result < 0) { - logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: MULTI-BYTE byte[] readBuffer = new byte[len]; result = PIGPIO.i2cReadDevice(handle, readBuffer, len); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if(result < 0) { - logger.error("\nERROR; I2C READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if(result != len) { - logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } //validate data read back is same as written if(!Arrays.equals(writeBuffer, readBuffer)) { - logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(writeBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(writeBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegister.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegister.java index 23b128fb..9ee8fcdb 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegister.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegister.java @@ -59,14 +59,14 @@ public static void main(String[] args) { piGpio.gpioInitialise(); logger.info("PIGPIO INITIALIZED"); - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + piGpio.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", piGpio.gpioHardwareRevision()); // open I2C channel/bus/device int handle = piGpio.i2cOpen(I2C_BUS, I2C_DEVICE, 0); - logger.info("PIGPIO I2C OPEN : " + handle); + logger.info("PIGPIO I2C OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } @@ -82,29 +82,29 @@ public static void main(String[] args) { // iterate over BYTE range of values, WRITE the byte then immediately // READ back the byte value and compare to make sure they are the same values. for (int b = 0; b < 255; b++) { - logger.info("[REG #" + register + "][W/R BYTE]"); + logger.info("[REG #{}][W/R BYTE]", register); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = piGpio.i2cWriteByteData(handle, register, (byte) b); if (result < 0) { - logger.error("\nERROR; I2C WRITE BYTE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE BYTE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: SINGLE RAW BYTE result = piGpio.i2cReadByteData(handle, register); if (result < 0) { - logger.error("\nERROR; I2C READ BYTE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ BYTE FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); int expected = b; int received = result; if (received != expected) { - logger.error("\nERROR; I2C READ BYTE FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; I2C READ BYTE FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -122,30 +122,30 @@ public static void main(String[] args) { // iterate over sample number of tests, WRITE the WORD value then immediately // READ back the WORD value and compare to make sure they are the same values. for (int b = 0; b < 100; b++) { - logger.info("[REG #" + register + "][W/R WORD]"); + logger.info("[REG #{}][W/R WORD]", register); Random rand = new Random(); int word = rand.nextInt(0xFFFF); // max 16 bits (2 bytes) // WRITE :: WORD VALUE (2-bytes) - logger.info(" (WRITE) 0x" + Integer.toHexString(word)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(word)); int result = piGpio.i2cWriteWordData(handle, register, word); if (result < 0) { - logger.error("\nERROR; I2C WRITE WORD FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE WORD FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: WORD VALUE (2-bytes) result = piGpio.i2cReadWordData(handle, register); if (result < 0) { - logger.error("\nERROR; I2C READ WORD FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ WORD FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); if (result != word) { - logger.error("\nERROR; I2C READ WORD FAILED: BYTE MISMATCH: expected=" + word + "; received=" + result); + logger.error("\nERROR; I2C READ WORD FAILED: BYTE MISMATCH: expected={}; received={}", word, result); System.exit(0); } } @@ -163,21 +163,21 @@ public static void main(String[] args) { // iterate over sample number of tests, WRITE the WORD value then immediately // READ back the WORD value and compare to make sure they are the same values. for (int b = 0; b < 100; b++) { - logger.info("[REG #" + register + "][XFER WORD]"); + logger.info("[REG #{}][XFER WORD]", register); Random rand = new Random(); int word = rand.nextInt(0xFFFF); // max 16 bits (2 bytes) // WRITE :: WORD VALUE (2-bytes) // READ :: WORD VALUE (2-bytes) - logger.info(" (WRITE) 0x" + Integer.toHexString(word)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(word)); int result = piGpio.i2cProcessCall(handle, register, word); if (result < 0) { - logger.error("\nERROR; I2C PROCESS WORD FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C PROCESS WORD FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); if (result != word) { - logger.error("\nERROR; I2C PROCESS WORD FAILED: BYTE MISMATCH: expected=" + word + "; received=" + result); + logger.error("\nERROR; I2C PROCESS WORD FAILED: BYTE MISMATCH: expected={}; received={}", word, result); System.exit(0); } } @@ -195,7 +195,7 @@ public static void main(String[] args) { // iterate over series of test values, WRITE the byte array then immediately // READ back the byte array values and compare to make sure they are the same values. for (int x = 1; x < 100; x++) { - logger.info("[REG #" + register + "][W/R BUFFER]"); + logger.info("[REG #{}][W/R BUFFER]", register); Random r = new Random(); int len = r.nextInt((20)) + 2; // minimum of 2 bytes @@ -203,34 +203,33 @@ public static void main(String[] args) { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = piGpio.i2cWriteI2CBlockData(handle, register, writeBuffer); if (result < 0) { - logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: MULTI-BYTE byte[] readBuffer = new byte[len]; result = piGpio.i2cReadI2CBlockData(handle, register, readBuffer); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if (result < 0) { - logger.error("\nERROR; I2C READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if (result != len) { - logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } //validate data read back is same as written if (!Arrays.equals(writeBuffer, readBuffer)) { - logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(writeBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(writeBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegisterRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegisterRaw.java index 781244ef..bd3da688 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegisterRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestI2CRegisterRaw.java @@ -54,21 +54,21 @@ public class TestI2CRegisterRaw { * @param args an array of {@link String} objects. */ public static void main(String[] args) { - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + PIGPIO.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", PIGPIO.gpioHardwareRevision()); int init = PIGPIO.gpioInitialise(); - logger.info("PIGPIO INITIALIZE: " + init); + logger.info("PIGPIO INITIALIZE: {}", init); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); System.exit(init); } // open I2C channel/bus/device int handle = PIGPIO.i2cOpen(I2C_BUS, I2C_DEVICE, 0); - logger.info("PIGPIO I2C OPEN : " + handle); + logger.info("PIGPIO I2C OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; I2C OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } @@ -84,29 +84,29 @@ public static void main(String[] args) { // iterate over BYTE range of values, WRITE the byte then immediately // READ back the byte value and compare to make sure they are the same values. for (int b = 0; b < 255; b++) { - logger.info("[REG #" + register + "][W/R BYTE]"); + logger.info("[REG #{}][W/R BYTE]", register); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = PIGPIO.i2cWriteByteData(handle, register, (byte) b); if (result < 0) { - logger.error("\nERROR; I2C WRITE BYTE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE BYTE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: SINGLE RAW BYTE result = PIGPIO.i2cReadByteData(handle, register); if (result < 0) { - logger.error("\nERROR; I2C READ BYTE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ BYTE FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); int expected = b; int received = result; if (received != expected) { - logger.error("\nERROR; I2C READ BYTE FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; I2C READ BYTE FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -124,30 +124,30 @@ public static void main(String[] args) { // iterate over sample number of tests, WRITE the WORD value then immediately // READ back the WORD value and compare to make sure they are the same values. for (int b = 0; b < 100; b++) { - logger.info("[REG #" + register + "][W/R WORD]"); + logger.info("[REG #{}][W/R WORD]", register); Random rand = new Random(); int word = rand.nextInt(0xFFFF); // max 16 bits (2 bytes) // WRITE :: WORD VALUE (2-bytes) - logger.info(" (WRITE) 0x" + Integer.toHexString(word)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(word)); int result = PIGPIO.i2cWriteWordData(handle, register, word); if (result < 0) { - logger.error("\nERROR; I2C WRITE WORD FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE WORD FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: WORD VALUE (2-bytes) result = PIGPIO.i2cReadWordData(handle, register); if (result < 0) { - logger.error("\nERROR; I2C READ WORD FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ WORD FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); if (result != word) { - logger.error("\nERROR; I2C READ WORD FAILED: BYTE MISMATCH: expected=" + word + "; received=" + result); + logger.error("\nERROR; I2C READ WORD FAILED: BYTE MISMATCH: expected={}; received={}", word, result); System.exit(0); } } @@ -165,21 +165,21 @@ public static void main(String[] args) { // iterate over sample number of tests, WRITE the WORD value then immediately // READ back the WORD value and compare to make sure they are the same values. for (int b = 0; b < 100; b++) { - logger.info("[REG #" + register + "][XFER WORD]"); + logger.info("[REG #{}][XFER WORD]", register); Random rand = new Random(); int word = rand.nextInt(0xFFFF); // max 16 bits (2 bytes) // WRITE :: WORD VALUE (2-bytes) // READ :: WORD VALUE (2-bytes) - logger.info(" (WRITE) 0x" + Integer.toHexString(word)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(word)); int result = PIGPIO.i2cProcessCall(handle, register, word); if (result < 0) { - logger.error("\nERROR; I2C PROCESS WORD FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C PROCESS WORD FAILED: ERROR CODE: {}", result); System.exit(result); } - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); if (result != word) { - logger.error("\nERROR; I2C PROCESS WORD FAILED: BYTE MISMATCH: expected=" + word + "; received=" + result); + logger.error("\nERROR; I2C PROCESS WORD FAILED: BYTE MISMATCH: expected={}; received={}", word, result); System.exit(0); } } @@ -197,7 +197,7 @@ public static void main(String[] args) { // iterate over series of test values, WRITE the byte array then immediately // READ back the byte array values and compare to make sure they are the same values. for (int x = 1; x < 100; x++) { - logger.info("[REG #" + register + "][W/R BUFFER]"); + logger.info("[REG #{}][W/R BUFFER]", register); Random r = new Random(); int len = r.nextInt((20)) + 2; // minimum of 2 bytes @@ -205,34 +205,33 @@ public static void main(String[] args) { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = PIGPIO.i2cWriteI2CBlockData(handle, register, writeBuffer, len); if (result < 0) { - logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } // READ :: MULTI-BYTE byte[] readBuffer = new byte[len]; result = PIGPIO.i2cReadI2CBlockData(handle, register, readBuffer, len); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if (result < 0) { - logger.error("\nERROR; I2C READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; I2C READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if (result != len) { - logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; I2C READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } //validate data read back is same as written if (!Arrays.equals(writeBuffer, readBuffer)) { - logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(writeBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; I2C READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(writeBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java index e9114ad1..369f1a8a 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java @@ -68,8 +68,8 @@ public static void main(String[] args) throws IOException { logger.info("PIGPIO INITIALIZED SUCCESSFULLY"); logger.info("-----------------------------------------------------"); - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + piGpio.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", piGpio.gpioHardwareRevision()); // set pin ALT modes for PWM piGpio.gpioSetMode(19, PiGpioMode.ALT5); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerial.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerial.java index 9b0964fe..1ff462bb 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerial.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerial.java @@ -60,18 +60,18 @@ public static void main(String[] args) throws Exception { piGpio.gpioInitialise(); logger.info("PIGPIO INITIALIZED"); - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + piGpio.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", piGpio.gpioHardwareRevision()); int handle = piGpio.serOpen(SERIAL_DEVICE, BAUD_RATE, 0); - logger.info("PIGPIO SERIAL OPEN : " + handle); + logger.info("PIGPIO SERIAL OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; SERIAL OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; SERIAL OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } - logger.info("SERIAL DATA DRAINED : " + piGpio.serDrain(handle)); + logger.info("SERIAL DATA DRAINED : {}", piGpio.serDrain(handle)); // iterate over BYTE range of values, WRITE the byte then immediately // READ back the byte value and compare to make sure they are the same values. @@ -79,10 +79,10 @@ public static void main(String[] args) throws Exception { logger.info("[SERIAL W/R BYTE]"); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = piGpio.serWriteByte(handle, (byte)b); if(result < 0) { - logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -92,25 +92,25 @@ public static void main(String[] args) throws Exception { // READ :: NUMBER OF BYTES AVAILABLE TO READ int available = piGpio.serDataAvailable(handle); - logger.info(" (AVAIL) " + available); + logger.info(" (AVAIL) {}", available); if(available != 1) { - logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received=" + available); + logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received={}", available); System.exit(result); } // READ :: SINGLE RAW BYTE result = piGpio.serReadByte(handle); - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: {}", result); System.exit(result); } int expected = b; int recevied = result; if(recevied != expected) { - logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + recevied); + logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected={}; received={}", expected, recevied); System.exit(0); } } @@ -126,10 +126,10 @@ public static void main(String[] args) throws Exception { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = piGpio.serWrite(handle, writeBuffer, len); if(result < 0) { - logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -139,40 +139,39 @@ public static void main(String[] args) throws Exception { // READ :: NUMBER OF BYTES AVAILABLE TO READ int available = piGpio.serDataAvailable(handle); - logger.info(" (AVAIL) " + available); + logger.info(" (AVAIL) {}", available); if(available != len) { - logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received=" + available); + logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received={}", available); System.exit(result); } // READ :: MULTI-BYTE byte[] readBuffer = new byte[available]; result = piGpio.serRead(handle, readBuffer, available); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if(result != len) { - logger.error("\nERROR; SERIAL READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; SERIAL READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } // validate buffer contents if(!Arrays.equals(writeBuffer, readBuffer)) { - logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(writeBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(writeBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } // close SERIAL channel int closed = piGpio.serClose(handle); - logger.info("PIGPIO SERIAL CLOSED : " + handle); + logger.info("PIGPIO SERIAL CLOSED : {}", handle); piGpio.shutdown(); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java index 6b28a4a2..ef011a94 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java @@ -53,25 +53,25 @@ public class TestSerialRaw { * @param args an array of {@link String} objects. */ public static void main(String[] args) throws InterruptedException { - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + PIGPIO.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", PIGPIO.gpioHardwareRevision()); int init = PIGPIO.gpioInitialise(); - logger.info("PIGPIO INITIALIZE: " + init); + logger.info("PIGPIO INITIALIZE: {}", init); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); System.exit(init); } int handle = PIGPIO.serOpen(SERIAL_DEVICE, BAUD_RATE, 0); - logger.info("PIGPIO SERIAL OPEN : " + handle); + logger.info("PIGPIO SERIAL OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; SERIAL OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; SERIAL OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } - logger.info("SERIAL DATA DRAINED : " + PIGPIO.serDrain(handle)); + logger.info("SERIAL DATA DRAINED : {}", PIGPIO.serDrain(handle)); // iterate over BYTE range of values, WRITE the byte then immediately // READ back the byte value and compare to make sure they are the same values. @@ -79,10 +79,10 @@ public static void main(String[] args) throws InterruptedException { logger.info("[SERIAL W/R BYTE]"); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = PIGPIO.serWriteByte(handle, (byte)b); if(result < 0) { - logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -92,25 +92,25 @@ public static void main(String[] args) throws InterruptedException { // READ :: NUMBER OF BYTES AVAILABLE TO READ int available = PIGPIO.serDataAvailable(handle); - logger.info(" (AVAIL) " + available); + logger.info(" (AVAIL) {}", available); if(available != 1) { - logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received=" + available); + logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received={}", available); System.exit(result); } // READ :: SINGLE RAW BYTE result = PIGPIO.serReadByte(handle); - logger.info(" (READ) 0x" + Integer.toHexString(result)); + logger.info(" (READ) 0x{}", Integer.toHexString(result)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: {}", result); System.exit(result); } int expected = b; int recevied = result; if(recevied != expected) { - logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + recevied); + logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected={}; received={}", expected, recevied); System.exit(0); } } @@ -126,10 +126,10 @@ public static void main(String[] args) throws InterruptedException { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = PIGPIO.serWrite(handle, writeBuffer, len); if(result < 0) { - logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -139,40 +139,39 @@ public static void main(String[] args) throws InterruptedException { // READ :: NUMBER OF BYTES AVAILABLE TO READ int available = PIGPIO.serDataAvailable(handle); - logger.info(" (AVAIL) " + available); + logger.info(" (AVAIL) {}", available); if(available != len) { - logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received=" + available); + logger.error("\nERROR; SERIAL AVAILABLE FAILED: expected=1; received={}", available); System.exit(result); } // READ :: MULTI-BYTE byte[] readBuffer = new byte[available]; result = PIGPIO.serRead(handle, readBuffer, available); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SERIAL READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if(result != len) { - logger.error("\nERROR; SERIAL READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; SERIAL READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } // validate buffer contents if(!Arrays.equals(writeBuffer, readBuffer)) { - logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(writeBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; SERIAL READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(writeBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } // close SERIAL channel int closed = PIGPIO.serClose(handle); - logger.info("PIGPIO SERIAL CLOSED : " + handle); + logger.info("PIGPIO SERIAL CLOSED : {}", handle); PIGPIO.gpioTerminate(); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpi.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpi.java index 49ff034b..0170ac62 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpi.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpi.java @@ -55,15 +55,15 @@ public static void main(String[] args) { PiGpio piGpio = PiGpio.newNativeInstance(); int init = piGpio.initialize(); - logger.info("PIGPIO INITIALIZED: " + init); + logger.info("PIGPIO INITIALIZED: {}", init); - logger.info("PIGPIO VERSION : " + piGpio.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + piGpio.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", piGpio.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", piGpio.gpioHardwareRevision()); int handle = piGpio.spiOpen(0, 50000, 0); - logger.info("PIGPIO SPI OPEN : " + handle); + logger.info("PIGPIO SPI OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; SPI OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; SPI OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } @@ -72,10 +72,10 @@ public static void main(String[] args) { for(int b = 0; b < 256; b++) { logger.info("[W/R BYTE]"); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = piGpio.spiWrite(handle, new byte[]{ (byte)b }, 1); if(result < 0) { - logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -83,17 +83,17 @@ public static void main(String[] args) { byte rx[] = new byte[1]; result = piGpio.spiRead(handle, rx, 1); - logger.info(" (READ) 0x" + StringUtil.toHexString(rx)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(rx)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SPI READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI READ FAILED: ERROR CODE: {}", result); System.exit(result); } int expected = b; int received = Byte.toUnsignedInt(rx[0]); if(received != expected) { - logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -103,19 +103,19 @@ public static void main(String[] args) { // WRITE :: SINGLE RAW BYTE byte tx[] = new byte[] {(byte)(b)}; byte rx[] = new byte[] {0}; - logger.info(" (WRITE) 0x" + StringUtil.toHexString(tx)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(tx)); int result = piGpio.spiXfer(handle, tx, rx, 1); - logger.info(" (READ) 0x" + StringUtil.toHexString(rx)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(rx)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SPI XFER FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI XFER FAILED: ERROR CODE: {}", result); System.exit(result); } if(b>0) { // ignore first read int expected = b-1; int received = Byte.toUnsignedInt(rx[0]); if (received != expected) { - logger.error("\nERROR; SPI XFER FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; SPI XFER FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -132,10 +132,10 @@ public static void main(String[] args) { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = piGpio.spiWrite(handle, writeBuffer, len); if(result < 0) { - logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -146,16 +146,16 @@ public static void main(String[] args) { // READ :: MULTI-BYTE byte[] readBuffer = new byte[len]; result = piGpio.spiRead(handle, readBuffer, len); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SPI READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if(result != len) { - logger.error("\nERROR; SPI READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; SPI READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } @@ -168,9 +168,8 @@ public static void main(String[] args) { expectBuffer.put(Arrays.copyOfRange(writeBuffer, 0, writeBuffer.length-1)); if(expectBuffer.get(0) != readBuffer[0]) { - logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(expectBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(expectBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpiRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpiRaw.java index e7fcf433..953fd733 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpiRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSpiRaw.java @@ -51,20 +51,20 @@ public class TestSpiRaw { * @param args an array of {@link String} objects. */ public static void main(String[] args) { - logger.info("PIGPIO VERSION : " + PIGPIO.gpioVersion()); - logger.info("PIGPIO HARDWARE : " + PIGPIO.gpioHardwareRevision()); + logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); + logger.info("PIGPIO HARDWARE : {}", PIGPIO.gpioHardwareRevision()); int init = PIGPIO.gpioInitialise(); - logger.info("PIGPIO INITIALIZE: " + init); + logger.info("PIGPIO INITIALIZE: {}", init); if(init < 0){ - logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: " + init); + logger.error("ERROR; PIGPIO INIT FAILED; ERROR CODE: {}", init); System.exit(init); } int handle = PIGPIO.spiOpen(0, 50000, 0); - logger.info("PIGPIO SPI OPEN : " + handle); + logger.info("PIGPIO SPI OPEN : {}", handle); if(handle < 0) { - logger.error("ERROR; SPI OPEN FAILED: ERROR CODE: " + handle); + logger.error("ERROR; SPI OPEN FAILED: ERROR CODE: {}", handle); System.exit(handle); } @@ -73,10 +73,10 @@ public static void main(String[] args) { for(int b = 0; b < 256; b++) { logger.info("[W/R BYTE]"); // WRITE :: SINGLE RAW BYTE - logger.info(" (WRITE) 0x" + Integer.toHexString(b)); + logger.info(" (WRITE) 0x{}", Integer.toHexString(b)); int result = PIGPIO.spiWrite(handle, new byte[]{ (byte)b }, 1); if(result < 0) { - logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -84,17 +84,17 @@ public static void main(String[] args) { byte rx[] = new byte[1]; result = PIGPIO.spiRead(handle, rx, 1); - logger.info(" (READ) 0x" + StringUtil.toHexString(rx)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(rx)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SPI READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI READ FAILED: ERROR CODE: {}", result); System.exit(result); } int expected = b; int received = Byte.toUnsignedInt(rx[0]); if(received != expected) { - logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -104,19 +104,19 @@ public static void main(String[] args) { // WRITE :: SINGLE RAW BYTE byte tx[] = new byte[] {(byte)(b)}; byte rx[] = new byte[] {0}; - logger.info(" (WRITE) 0x" + StringUtil.toHexString(tx)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(tx)); int result = PIGPIO.spiXfer(handle, tx, rx, 1); - logger.info(" (READ) 0x" + StringUtil.toHexString(rx)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(rx)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SPI XFER FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI XFER FAILED: ERROR CODE: {}", result); System.exit(result); } if(b>0) { // ignore first read int expected = b-1; int received = Byte.toUnsignedInt(rx[0]); if (received != expected) { - logger.error("\nERROR; SPI XFER FAILED: BYTE MISMATCH: expected=" + expected + "; received=" + received); + logger.error("\nERROR; SPI XFER FAILED: BYTE MISMATCH: expected={}; received={}", expected, received); System.exit(0); } } @@ -133,10 +133,10 @@ public static void main(String[] args) { r.nextBytes(writeBuffer); // WRITE :: MULTI-BYTE - logger.info(" (WRITE) 0x" + StringUtil.toHexString(writeBuffer)); + logger.info(" (WRITE) 0x{}", StringUtil.toHexString(writeBuffer)); int result = PIGPIO.spiWrite(handle, writeBuffer, len); if(result < 0) { - logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI WRITE FAILED: ERROR CODE: {}", result); System.exit(result); } @@ -147,16 +147,16 @@ public static void main(String[] args) { // READ :: MULTI-BYTE byte[] readBuffer = new byte[len]; result = PIGPIO.spiRead(handle, readBuffer, len); - logger.info(" (READ) 0x" + StringUtil.toHexString(readBuffer)); + logger.info(" (READ) 0x{}", StringUtil.toHexString(readBuffer)); logger.info(""); if(result < 0) { - logger.error("\nERROR; SPI READ FAILED: ERROR CODE: " + result); + logger.error("\nERROR; SPI READ FAILED: ERROR CODE: {}", result); System.exit(result); } // validate read length if(result != len) { - logger.error("\nERROR; SPI READ FAILED: LENGTH MISMATCH: " + result); + logger.error("\nERROR; SPI READ FAILED: LENGTH MISMATCH: {}", result); System.exit(result); } @@ -169,9 +169,8 @@ public static void main(String[] args) { expectBuffer.put(Arrays.copyOfRange(writeBuffer, 0, writeBuffer.length-1)); if(expectBuffer.get(0) != readBuffer[0]) { - logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected=" + - StringUtil.toHexString(expectBuffer) + "; received=" + - StringUtil.toHexString(readBuffer)); + logger.error("\nERROR; SPI READ FAILED: BYTE MISMATCH: expected={}; received={}", + StringUtil.toHexString(expectBuffer), StringUtil.toHexString(readBuffer)); System.exit(0); } } diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java index a50cf5c1..89f5ea2a 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java @@ -61,7 +61,7 @@ public static synchronized void load(String fileName, String libName) { // first, make sure that this library has not already been previously loaded if (loadedLibraries.contains(fileName)) { - logger.warn("Library [" + fileName + "] has already been loaded; no need to load again."); + logger.warn("Library [{}] has already been loaded; no need to load again.", fileName); return; } @@ -74,7 +74,7 @@ public static synchronized void load(String fileName, String libName) { // if the overriding library path is set to "system", then attempt to use the system resolved library paths if (libpath.equalsIgnoreCase("system")) { - logger.debug("Attempting to load library using {pi4j.library.path} system resolved library name: [" + libName + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} system resolved library name: [{}]", libName); try { // load library from JVM system library path; based on library name System.loadLibrary(libName); @@ -100,7 +100,7 @@ else if (libpath.equalsIgnoreCase("local")) { } // build path based on lib directory and lib filename String path = Paths.get(libpath, fileName).toString(); - logger.debug("Attempting to load library using {pi4j.library.path} defined path: [" + path + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} defined path: [{}]", path); try { // load library from local path of this JAR file System.load(path); @@ -120,12 +120,12 @@ else if (libpath.equalsIgnoreCase("local")) { else { // build path based on lib directory and lib filename String path = Paths.get(libpath, fileName).toString(); - logger.debug("Attempting to load library using {pi4j.library.path} defined path: [" + path + "]"); + logger.debug("Attempting to load library using {pi4j.library.path} defined path: [{}]", path); try { // load library from user defined absolute path provided via pi4j.library.path} System.load(path); } catch (UnsatisfiedLinkError ex) { - logger.error("Unable to load/link [" + fileName + "] using path: [" + path + "]", ex); + logger.error("Unable to load/link [{}] using path: [{}]", fileName, path, ex); String exceptMessage; // no guarantee the except pertains to ELF miss-match so check MSG content if (ex.getMessage().contains("wrong ELF class")) { @@ -144,7 +144,7 @@ else if (libpath.equalsIgnoreCase("local")) { } throw new UnsatisfiedLinkError(exceptMessage); } catch (Exception ex) { - logger.error("Unable to load/link [" + fileName + "] using path: [" + path + "]", ex); + logger.error("Unable to load/link [{}] using path: [{}]", fileName, path, ex); throw new UnsatisfiedLinkError("Pi4J was unable to extract and load the native library [" + path + "] from the embedded resources inside this JAR [" + NativeLibraryLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath() + @@ -177,12 +177,12 @@ else if (libpath.equalsIgnoreCase("local")) { // include the CPU architecture in the embedded path String path = "/lib/" + osArch + "/" + fileName; - logger.debug("Attempting to load library [" + fileName + "] using path: [" + path + "]"); + logger.debug("Attempting to load library [{}] using path: [{}]", fileName, path); try { loadLibraryFromClasspath(path); - logger.debug("Library [" + fileName + "] loaded successfully using embedded resource file: [" + path + "]"); + logger.debug("Library [{}] loaded successfully using embedded resource file: [{}]", fileName, path); } catch (UnsatisfiedLinkError e) { - logger.error("Unable to load/link [" + fileName + "] using path: [" + path + "]", e); + logger.error("Unable to load/link [{}] using path: [{}]", fileName, path, e); String exceptMessage; // no guarantee the except pertains to ELF miss-match so check MSG content if (e.getMessage().contains("wrong ELF class")) { @@ -202,7 +202,7 @@ else if (libpath.equalsIgnoreCase("local")) { } throw new UnsatisfiedLinkError(exceptMessage); } catch (IOException e) { - logger.error("Unable to load/link [" + fileName + "] using path: [" + path + "]", e); + logger.error("Unable to load/link [{}] using path: [{}]", fileName, path, e); throw new UnsatisfiedLinkError("Pi4J was unable to extract and load the native library [" + path + "] from the embedded resources inside this JAR [" + NativeLibraryLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath() + diff --git a/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java b/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java index 1b39c2f3..3f6eead0 100644 --- a/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java +++ b/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java @@ -110,8 +110,9 @@ public Map providers() { public T provider(Class providerClass) throws ProviderNotFoundException, ProviderInterfaceException { if(!providerClass.isInterface()){ - logger.warn("Provider type [" + providerClass.getName() + "] requested; this is not an 'Interface'" + - " and may not return a valid provider or may not be able to cast to the concrete class."); + logger.warn("Provider type [{}] requested; this is not an 'Interface'" + + "and may not return a valid provider or may not be able to cast to the concrete class.", + providerClass.getName()); } for (Provider p : providers.values()) { diff --git a/pi4j-core/src/main/java/com/pi4j/provider/impl/DefaultRuntimeProviders.java b/pi4j-core/src/main/java/com/pi4j/provider/impl/DefaultRuntimeProviders.java index ed2c5775..45799a0f 100644 --- a/pi4j-core/src/main/java/com/pi4j/provider/impl/DefaultRuntimeProviders.java +++ b/pi4j-core/src/main/java/com/pi4j/provider/impl/DefaultRuntimeProviders.java @@ -148,8 +148,9 @@ public Map all(){ public Map all(Class providerClass) { if(!providerClass.isInterface()){ - logger.warn("Provider type [" + providerClass.getName() + "] requested; this is not an 'Interface'" + - " and make not return a valid provider or may not be able to cast to the concrete class."); + logger.warn("Provider type [{}] requested; this is not an 'Interface' and make not return a valid " + + "provider or may not be able to cast to the concrete class.", + providerClass.getName()); } // create a map of providers that extend of the given io class diff --git a/pi4j-core/src/main/java/com/pi4j/registry/impl/DefaultRuntimeRegistry.java b/pi4j-core/src/main/java/com/pi4j/registry/impl/DefaultRuntimeRegistry.java index a6b93d53..a244aaaf 100644 --- a/pi4j-core/src/main/java/com/pi4j/registry/impl/DefaultRuntimeRegistry.java +++ b/pi4j-core/src/main/java/com/pi4j/registry/impl/DefaultRuntimeRegistry.java @@ -153,7 +153,7 @@ public synchronized T remove(String id) shutdownInstance.shutdown(runtime.context()); long took = System.currentTimeMillis() - start; if (took > 10) - logger.warn("Shutting down of IO " + shutdownInstance.getId() + " took " + took + "ms"); + logger.info("Shutting down of IO {} took {}ms", shutdownInstance.getId(), took); } catch (LifecycleException e) { logger.error(e.getMessage(), e); throw new IOShutdownException(shutdownInstance, e); diff --git a/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java b/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java index 1dffb9c0..f88186dd 100644 --- a/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java +++ b/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java @@ -304,7 +304,7 @@ public Runtime initialize() throws InitializeException { context().config().getProviders().forEach(provider -> { Provider replaced = providers.put(provider.getType(), provider); if (replaced != null) { - logger.warn("Replacing auto detected provider {} {} with provider {} from context config", + logger.info("Replacing auto detected provider {} {} with provider {} from context config", replaced.getType(), replaced.getName(), provider.getName()); } }); @@ -375,11 +375,11 @@ private void addProvider(Provider provider, Map providers) { if (existingProvider.getName().equals(provider.getName())) throw new InitializeException( provider.getType() + " with name " + provider.getName() + " is already registered."); - logger.warn("Ignoring provider {} {} with priority {} as lower priority than {} which has priority {}", + logger.info("Ignoring provider {} {} with priority {} as lower priority than {} which has priority {}", provider.getType(), provider.getName(), provider.getPriority(), existingProvider.getName(), existingProvider.getPriority()); } else { - logger.warn("Replacing provider {} {} with priority {} with provider {} with higher priority {}", + logger.info("Replacing provider {} {} with priority {} with provider {} with higher priority {}", existingProvider.getType(), existingProvider.getName(), existingProvider.getPriority(), provider.getName(), provider.getPriority()); providers.put(provider.getType(), provider); diff --git a/pi4j-core/src/main/java/com/pi4j/util/ExecutorPool.java b/pi4j-core/src/main/java/com/pi4j/util/ExecutorPool.java index e1ea803e..5b0e6ebf 100644 --- a/pi4j-core/src/main/java/com/pi4j/util/ExecutorPool.java +++ b/pi4j-core/src/main/java/com/pi4j/util/ExecutorPool.java @@ -47,18 +47,19 @@ public void destroy() { } private void shutdownExecutor(String name, ExecutorService executor) { - logger.info("Shutting down executor pool " + name); + logger.info("Shutting down executor pool {}", name); try { List tasks = executor.shutdownNow(); if (!tasks.isEmpty()) { - logger.warn("The following " + tasks.size() + " tasks were never started for executor " + name + " :"); + logger.warn("The following {} tasks were never started for executor {} :", tasks.size(), name); for (Runnable runnable : tasks) { + //noinspection StringConcatenationArgumentToLogCall avoid risk of multithreaded access to arbitrary objects via async logging logger.warn(" " + runnable); } } if (!executor.awaitTermination(5, TimeUnit.SECONDS)) - logger.error("Executor " + name + " did not stop after " + 5 + "s!"); + logger.error("Executor {} did not stop after 5s!", name); } catch (InterruptedException e) { logger.error("Was interrupted while shutting down tasks"); } diff --git a/pi4j-test/src/main/java/com/pi4j/test/About.java b/pi4j-test/src/main/java/com/pi4j/test/About.java index 07875e57..ad4d9f47 100644 --- a/pi4j-test/src/main/java/com/pi4j/test/About.java +++ b/pi4j-test/src/main/java/com/pi4j/test/About.java @@ -66,7 +66,7 @@ public void enumerateProviders(Context context, String title) { logger.info(title); logger.info("====================================================="); for (Provider provider : context.providers().all().values()) { - logger.info(" " + provider.name() + " [" + provider.id() + "]; " + provider.type()); + logger.info(" {} [{}]; {}", provider.name(), provider.id(), provider.type()); } } @@ -78,10 +78,10 @@ public void enumerateProviders(Context context, String title) { */ public void enumerateProviders(Context context, IOType ioType) { logger.info("====================================================="); - logger.info(ioType + " PROVIDERS"); + logger.info("{} PROVIDERS", ioType); logger.info("====================================================="); for(var provider : context.providers().all(ioType).values()){ - logger.info(" " + provider.name() + " [" + provider.id() + "]; " + provider.type()); + logger.info(" {} [{}]; {}", provider.name(), provider.id(), provider.type()); } } @@ -95,7 +95,7 @@ public void enumeratePlatforms(Context context) { logger.info("PLATFORMS"); logger.info("====================================================="); for (Platform platform : context.platforms().all().values()) { - logger.info(" " + platform.name() + " [" + platform.id() + "]; " + platform.getDescription()); + logger.info(" {} [{}]; {}", platform.name(), platform.id(), platform.getDescription()); } } diff --git a/pi4j-test/src/main/java/com/pi4j/test/Main.java b/pi4j-test/src/main/java/com/pi4j/test/Main.java index a1289e47..8ec15df9 100644 --- a/pi4j-test/src/main/java/com/pi4j/test/Main.java +++ b/pi4j-test/src/main/java/com/pi4j/test/Main.java @@ -110,7 +110,7 @@ public static void main(String[] args) { input.bind(AnalogOutputBinding.newInstance(output1, output2)); - logger.info("Inpur: " + input.name()); + logger.info("Inpur: {}", input.name()); //((TestAnalogInput)input).test(21).test(22).test(23); //output.value(12); diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java index 22bae0fe..63ce3780 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java @@ -150,8 +150,8 @@ public void testRawDataStream() throws IOException { // read sample data using input stream byte[] result = i2c.in().readNBytes(sample.length); - logger.info("[SAMPLE DATA] - 0x" + StringUtil.toHexString(sample)); - logger.info("[READ DATA ] - 0x" + StringUtil.toHexString(result)); + logger.info("[SAMPLE DATA] - 0x{}", StringUtil.toHexString(sample)); + logger.info("[READ DATA ] - 0x{}", StringUtil.toHexString(result)); // copare sample data against returned read data assertArrayEquals(sample, result); diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java index 1b16ed1c..49bc4ae5 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java @@ -151,8 +151,8 @@ public void testRawDataStream() throws IOException { // read sample data using input stream byte[] result = spi.in().readNBytes(sample.length); - logger.info("[SAMPLE DATA] - 0x" + StringUtil.toHexString(sample)); - logger.info("[READ DATA ] - 0x" + StringUtil.toHexString(result)); + logger.info("[SAMPLE DATA] - 0x{}", StringUtil.toHexString(sample)); + logger.info("[READ DATA ] - 0x{}", StringUtil.toHexString(result)); // compare sample data against returned read data assertArrayEquals(sample, result); diff --git a/plugins/pi4j-plugin-gpiod/src/main/java/com/pi4j/plugin/gpiod/provider/gpio/digital/GpioDDigitalInput.java b/plugins/pi4j-plugin-gpiod/src/main/java/com/pi4j/plugin/gpiod/provider/gpio/digital/GpioDDigitalInput.java index 5ed18169..68e41f7e 100644 --- a/plugins/pi4j-plugin-gpiod/src/main/java/com/pi4j/plugin/gpiod/provider/gpio/digital/GpioDDigitalInput.java +++ b/plugins/pi4j-plugin-gpiod/src/main/java/com/pi4j/plugin/gpiod/provider/gpio/digital/GpioDDigitalInput.java @@ -99,7 +99,7 @@ private void shutdownInputListener() { } } - logger.info("Shutdown input listener for " + this.id); + logger.info("Shutdown input listener for {}", this.id); } @Override diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInput.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInput.java index 0444c296..6484cfa8 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInput.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInput.java @@ -66,15 +66,15 @@ public LinuxFsDigitalInput(LinuxGpio gpio, DigitalInputProvider provider, Digita @Override public DigitalInput initialize(Context context) throws InitializeException { - logger.trace("initializing GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("initializing GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); // [EXPORT] requested GPIO pin if its not already exported try { if(!gpio.isExported()) { - logger.trace("exporting GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("exporting GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); gpio.export(); } else{ - logger.trace("GPIO [" + this.config.address() + "] is already exported; " + gpio.getPinPath()); + logger.trace("GPIO [{}] is already exported; {}", this.config.address(), gpio.getPinPath()); } } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -83,7 +83,7 @@ public DigitalInput initialize(Context context) throws InitializeException { // [INPUT] configure GPIO pin direction as digital input try { - logger.trace("set direction [IN] on GPIO " + gpio.getPinPath()); + logger.trace("set direction [IN] on GPIO {}", gpio.getPinPath()); gpio.direction(LinuxGpio.Direction.IN); } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -121,11 +121,13 @@ else if(this.config.pull() == PullResistance.OFF){ super.initialize(context); // [MONITOR] start background monitoring thread for GPIO state changes - logger.trace("start monitoring thread for GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("start monitoring thread for GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); Runnable monitorTask = () -> { try { // create file system watcher - logger.trace("monitoring thread watching GPIO [" + LinuxFsDigitalInput.this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("monitoring thread watching GPIO [{}]; {}", + LinuxFsDigitalInput.this.config.address(), + gpio.getPinPath()); WatchService watchService = FileSystems.getDefault().newWatchService(); WatchKey key; @@ -167,10 +169,10 @@ else if(this.config.pull() == PullResistance.OFF){ /** {@inheritDoc} */ @Override public DigitalInput shutdown(Context context) throws ShutdownException { - logger.trace("shutdown GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("shutdown GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); // this line will execute immediately, not waiting for your task to complete - logger.trace("shutdown monitoring thread for GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("shutdown monitoring thread for GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); if (this.inputListener != null) { if (!this.inputListener.cancel(true)) logger.error("Failed to cancel input listener!"); @@ -181,7 +183,7 @@ public DigitalInput shutdown(Context context) throws ShutdownException { // un-export the GPIO pin from the Linux file system impl try { - logger.trace("un-exporting GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("un-exporting GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); gpio.unexport(); } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -194,7 +196,7 @@ public DigitalInput shutdown(Context context) throws ShutdownException { @Override public DigitalState state() { - logger.trace("get state on GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("get state on GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); try { // acquire actual GPIO state directly from Linux file system impl this.state = gpio.state(); diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutput.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutput.java index 7daff4e1..455a8408 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutput.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutput.java @@ -62,15 +62,15 @@ public LinuxFsDigitalOutput(LinuxGpio gpio, DigitalOutputProvider provider, Digi @Override public DigitalOutput initialize(Context context) throws InitializeException { - logger.trace("initializing GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("initializing GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); // [EXPORT] requested GPIO pin if its not already exported try { if(!gpio.isExported()) { - logger.trace("exporting GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("exporting GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); gpio.export(); } else{ - logger.trace("GPIO [" + this.config.address() + "] is already exported; " + gpio.getPinPath()); + logger.trace("GPIO [{}] is already exported; {}", this.config.address(), gpio.getPinPath()); } } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -79,7 +79,7 @@ public DigitalOutput initialize(Context context) throws InitializeException { // [OUTPUT] configure GPIO pin direction as digital output try { - logger.trace("set direction [OUT] on GPIO " + gpio.getPinPath()); + logger.trace("set direction [OUT] on GPIO {}", gpio.getPinPath()); gpio.direction(LinuxGpio.Direction.OUT); } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -104,7 +104,7 @@ public DigitalOutput initialize(Context context) throws InitializeException { /** {@inheritDoc} */ @Override public DigitalOutput shutdown(Context context) throws ShutdownException { - logger.trace("shutdown GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("shutdown GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); // -------------------------------------------------------------------------- // [ATTENTION] @@ -129,7 +129,7 @@ public DigitalOutput shutdown(Context context) throws ShutdownException { // otherwise ... un-export the GPIO pin from the Linux file system impl try { - logger.trace("un-exporting GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("un-exporting GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); gpio.unexport(); } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -143,7 +143,7 @@ public DigitalOutput shutdown(Context context) throws ShutdownException { /** {@inheritDoc} */ @Override public DigitalOutput state(DigitalState state) throws IOException { - logger.trace("set state [" + state.getName() + "] on GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("set state [{}] on GPIO [{}]; {}", state.getName(), this.config.address(), gpio.getPinPath()); try { // apply requested GPIO state via Linux FS gpio.state(state); @@ -156,7 +156,7 @@ public DigitalOutput state(DigitalState state) throws IOException { @Override public DigitalState state() { - logger.trace("get state on GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("get state on GPIO [{}]; {}", this.config.address(), gpio.getPinPath()); try { // acquire actual GPIO state directly from Linux file system impl @@ -165,7 +165,10 @@ public DigitalState state() { // update/sync internal state tracking variable if mismatch if(this.state != currentState) { this.state = currentState; - logger.trace("state mismatch detected; sync internal state [" + this.state.getName() + "] on GPIO [" + this.config.address() + "]; " + gpio.getPinPath()); + logger.trace("state mismatch detected; sync internal state [{}] on GPIO [{}]; {}", + this.state.getName(), + this.config.address(), + gpio.getPinPath()); } } catch (java.io.IOException e) { logger.error(e.getMessage(), e); diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwm.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwm.java index a264023c..4f83384a 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwm.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwm.java @@ -68,7 +68,7 @@ public LinuxFsPwm(LinuxPwm pwm, PwmProvider provider, PwmConfig config) { */ @Override public Pwm initialize(Context context) throws InitializeException { - logger.trace("initializing PWM [" + this.config.address() + "]; " + pwm.getPwmPath()); + logger.trace("initializing PWM [{}]; {}", this.config.address(), pwm.getPwmPath()); // first determine if this PWM chipset supports this PWM channel/pin number try { @@ -83,12 +83,12 @@ public Pwm initialize(Context context) throws InitializeException { // [EXPORT] requested PWM channel if its not already exported try { if(!pwm.isExported()) { - logger.trace("exporting PWM [" + this.config.address() + "]; " + pwm.getPwmPath()); + logger.trace("exporting PWM [{}]; {}", this.config.address(), pwm.getPwmPath()); pwm.export(); // Delay to allow the SSD to persist the new directory and device partitions Thread.sleep(70); } else{ - logger.trace("PWM [" + this.config.address() + "] is already exported; " + pwm.getPwmPath()); + logger.trace("PWM [{}] is already exported; {}", this.config.address(), pwm.getPwmPath()); } } catch (java.io.IOException e) { logger.error(e.getMessage(), e); @@ -123,22 +123,22 @@ public Pwm on() throws IOException { long period = Frequency.nanoseconds(this.frequency); // set PWM period in nanoseconds based on configured frequency - logger.trace("set 'period' of PWM [" + this.config.address() + "] to [" + Long.toUnsignedString(period) + "]; " + pwm.getPwmPath()); + logger.trace("set 'period' of PWM [{}] to [{}]; {}", this.config.address(), Long.toUnsignedString(period), pwm.getPwmPath()); pwm.period(period); // calculate duty cycle nanoseconds from configured duty cycle percentage long dcycle = Math.round(period * this.dutyCycle / 100); // set PWM duty-cycle nanoseconds - logger.trace("set 'duty_cycle' of PWM [" + this.config.address() + "] to [" + dcycle + "]; " + pwm.getPwmPath()); + logger.trace("set 'duty_cycle' of PWM [{}] to [{}]; {}", this.config.address(), dcycle, pwm.getPwmPath()); pwm.dutyCycle(dcycle); // set PWM polarity - logger.trace("set 'polarity' of PWM [" + this.config.address() + "] to [" + this.polarity.getName() + "]; " + pwm.getPwmPath()); + logger.trace("set 'polarity' of PWM [{}] to [{}]; {}", this.config.address(), this.polarity.getName(), pwm.getPwmPath()); pwm.polarity( (this.polarity == PwmPolarity.INVERSED) ? LinuxPwm.Polarity.INVERSED : LinuxPwm.Polarity.NORMAL); // enable PWM signal - logger.trace("enable PWM [" + this.config.address() + "]; " + pwm.getPwmPath()); + logger.trace("enable PWM [{}]; {}", this.config.address(), pwm.getPwmPath()); pwm.enable(); // update tracking state @@ -157,7 +157,7 @@ public Pwm on() throws IOException { public Pwm off() throws IOException{ try { // disable PWM - logger.trace("disable PWM [" + this.config.address() + "]; " + pwm.getPwmPath()); + logger.trace("disable PWM [{}]; {}", this.config.address(), pwm.getPwmPath()); pwm.disable(); // update tracking state @@ -200,7 +200,7 @@ public int getActualFrequency() throws IOException { /** {@inheritDoc} */ @Override public Pwm shutdown(Context context) throws ShutdownException { - logger.trace("shutdown PWM [" + this.config.address() + "]; " + pwm.getPwmPath()); + logger.trace("shutdown PWM [{}]; {}", this.config.address(), pwm.getPwmPath()); // -------------------------------------------------------------------------- // [ATTENTION] @@ -223,7 +223,7 @@ public Pwm shutdown(Context context) throws ShutdownException { // otherwise ... un-export the GPIO pin from the Linux file system impl try { - logger.trace("un-exporting PWM [" + this.config.address() + "]; " + pwm.getPwmPath()); + logger.trace("un-exporting PWM [{}]; {}", this.config.address(), pwm.getPwmPath()); if(pwm.isExported()) { pwm.unexport(); } diff --git a/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/serial/MockSerial.java b/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/serial/MockSerial.java index cbba77e8..3505abc3 100644 --- a/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/serial/MockSerial.java +++ b/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/serial/MockSerial.java @@ -70,7 +70,7 @@ public MockSerial(SerialProvider provider, SerialConfig config){ logger.info(Mock.SERIAL_PROVIDER_NAME); logger.info("::"); logger.info(this.id); - logger.info("] :: OPEN(DEVICE=" + config.device() + "; BAUD=" + config.baud() + ")"); + logger.info("] :: OPEN(DEVICE={}; BAUD={})", config.device(), config.baud()); logger.info(""); } @@ -87,7 +87,7 @@ public void close() { logger.info(Mock.SERIAL_PROVIDER_NAME); logger.info("::"); logger.info(this.id); - logger.info("] :: CLOSE(DEVICE=" + config.device() + "; BAUD=" + config.baud() + ")"); + logger.info("] :: CLOSE(DEVICE={}; BAUD={})", config.device(), config.baud()); logger.info(""); super.close(); }