Skip to content

Commit

Permalink
Merge pull request #370 from ylexus/develop
Browse files Browse the repository at this point in the history
fix unnecessary sting concatenation in logging statements; downgrade logging level to INFO in BAU places
  • Loading branch information
eitch authored Jul 29, 2024
2 parents 7152cda + 03fcb51 commit 9c4a54a
Show file tree
Hide file tree
Showing 35 changed files with 297 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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")) {
Expand All @@ -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() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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")) {
Expand All @@ -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() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("-----------------------------------------------------");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("-----------------------------------------------------");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
}
});

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
}
});

Expand All @@ -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);

Expand Down
Loading

0 comments on commit 9c4a54a

Please sign in to comment.