[dscalarm] Add details in bridge handler error log to help find the problem (#17051)

* [dscalarm] Add details in bridge handler error log to help find the problem

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
jimtng 2024-07-22 19:22:09 +10:00 committed by GitHub
parent b58580a566
commit 6d63e8c37e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 55 additions and 55 deletions

View File

@ -96,7 +96,7 @@ public class DSCAlarmMessage {
data = message.substring(3);
}
} catch (Exception e) {
logger.error("processDSCAlarmMessage(): Error processing message: ({}) ", message, e);
logger.warn("processDSCAlarmMessage(): Error processing message: ({}) ", message, e);
return;
}

View File

@ -71,7 +71,7 @@ public class DSCAlarmBridgeDiscovery extends AbstractDiscoveryService {
logger.trace("addBridge(): '{}' was added to inbox.", thingUID);
} catch (Exception e) {
logger.error("addBridge(): Error", e);
logger.warn("addBridge(): Error", e);
}
}
}

View File

@ -71,10 +71,10 @@ public class EnvisalinkBridgeDiscovery {
lowIP = convertIPToNumber(subnetInfo.getLowAddress());
highIP = convertIPToNumber(subnetInfo.getHighAddress());
} catch (IllegalArgumentException e) {
logger.error("discoverBridge(): Illegal Argument Exception - {}", e.toString());
logger.warn("discoverBridge(): Illegal Argument Exception - {}", e.toString());
return;
} catch (Exception e) {
logger.error("discoverBridge(): Error - Unable to get Subnet Information! {}", e.toString());
logger.warn("discoverBridge(): Error - Unable to get Subnet Information! {}", e.toString());
return;
}

View File

@ -341,7 +341,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
sendCommand(DSCAlarmCode.StatusReport);
}
} else {
logger.error("Not Connected to the DSC Alarm!");
logger.warn("Not Connected to the DSC Alarm!");
connect();
}
}
@ -380,7 +380,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
}
} else {
logger.error("checkThings(): Thing handler not found!");
logger.warn("checkThings(): Thing handler not found! Thing: {}", thing.getUID());
}
}
}
@ -648,7 +648,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
}
if (password == null) {
logger.error("sendCommand(): No password!");
logger.warn("sendCommand(): No password!");
break;
}
data = password;
@ -669,14 +669,14 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
break;
case CommandOutputControl: /* 020 */
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-8]")) {
logger.error(
logger.warn(
"sendCommand(): Partition number must be a single character string from 1 to 8, it was: {}",
dscAlarmData[0]);
break;
}
if (dscAlarmData[1] == null || !dscAlarmData[1].matches("[1-4]")) {
logger.error(
logger.warn(
"sendCommand(): Output number must be a single character string from 1 to 4, it was: {}",
dscAlarmData[1]);
break;
@ -693,7 +693,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
case PartitionArmControlStay: /* 031 */
case PartitionArmControlZeroEntryDelay: /* 032 */
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-8]")) {
logger.error(
logger.warn(
"sendCommand(): Partition number must be a single character string from 1 to 8, it was: {}",
dscAlarmData[0]);
break;
@ -704,14 +704,14 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
case PartitionArmControlWithUserCode: /* 033 */
case PartitionDisarmControl: /* 040 */
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-8]")) {
logger.error(
logger.warn(
"sendCommand(): Partition number must be a single character string from 1 to 8, it was: {}",
dscAlarmData[0]);
break;
}
if (userCode == null || userCode.length() < 4 || userCode.length() > 6) {
logger.error("sendCommand(): User Code is invalid, must be between 4 and 6 chars");
logger.warn("sendCommand(): User Code is invalid, must be between 4 and 6 chars");
break;
}
@ -732,7 +732,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
case TimeDateBroadcastControl: /* 056 */
case TemperatureBroadcastControl: /* 057 */
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[0-1]")) {
logger.error("sendCommand(): Value must be a single character string of 0 or 1: {}",
logger.warn("sendCommand(): Value must be a single character string of 0 or 1: {}",
dscAlarmData[0]);
break;
}
@ -741,7 +741,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
break;
case TriggerPanicAlarm: /* 060 */
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-3]")) {
logger.error("sendCommand(): FAPcode must be a single character string from 1 to 3, it was: {}",
logger.warn("sendCommand(): FAPcode must be a single character string from 1 to 3, it was: {}",
dscAlarmData[1]);
break;
}
@ -752,7 +752,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
if (dscAlarmProtocol.equals(DSCAlarmProtocol.ENVISALINK_TPI)) {
if (dscAlarmData[0] == null || dscAlarmData[0].length() != 1
|| !dscAlarmData[0].matches("[0-9]|A|#|\\*")) {
logger.error(
logger.warn(
"sendCommand(): \'keystroke\' must be a single character string from 0 to 9, *, #, or A, it was: {}",
dscAlarmData[0]);
break;
@ -760,7 +760,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
} else if (dscAlarmProtocol.equals(DSCAlarmProtocol.IT100_API)) {
if (dscAlarmData[0] == null || dscAlarmData[0].length() != 1
|| !dscAlarmData[0].matches("[0-9]|\\*|#|F|A|P|[a-e]|<|>|=|\\^|L")) {
logger.error(
logger.warn(
"sendCommand(): \'keystroke\' must be a single character string from 0 to 9, *, #, F, A, P, a to e, <, >, =, or ^, it was: {}",
dscAlarmData[0]);
break;
@ -771,7 +771,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
validCommand = true;
break;
} catch (InterruptedException e) {
logger.error("sendCommand(): \'keystroke\': Error with Long Key Press!");
logger.warn("sendCommand(): \'keystroke\': Error with Long Key Press!");
break;
}
}
@ -789,7 +789,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
if (dscAlarmData[0] == null || dscAlarmData[0].length() > 6
|| !dscAlarmData[0].matches("(\\d|#|\\*)+")) {
logger.error(
logger.warn(
"sendCommand(): \'keysequence\' must be a string of up to 6 characters consiting of 0 to 9, *, or #, it was: {}",
dscAlarmData[0]);
break;
@ -799,7 +799,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
break;
case CodeSend: /* 200 */
if (userCode == null || userCode.length() < 4 || userCode.length() > 6) {
logger.error("sendCommand(): Access Code is invalid, must be between 4 and 6 chars");
logger.warn("sendCommand(): Access Code is invalid, must be between 4 and 6 chars");
break;
}
@ -820,7 +820,7 @@ public abstract class DSCAlarmBaseBridgeHandler extends BaseBridgeHandler {
successful = true;
logger.debug("sendCommand(): '{}' Command Sent - {}", dscAlarmCode, confidentialData ? "***" : cmd);
} else {
logger.error("sendCommand(): Command '{}' Not Sent - Invalid!", dscAlarmCode);
logger.warn("sendCommand(): Command '{}' Not Sent - Invalid!", dscAlarmCode);
}
return successful;

View File

@ -104,16 +104,16 @@ public class EnvisalinkBridgeHandler extends DSCAlarmBaseBridgeHandler {
setConnected(true);
} catch (UnknownHostException unknownHostException) {
logger.error("openConnection(): Unknown Host Exception: {}", unknownHostException.getMessage());
logger.warn("openConnection(): Unknown Host Exception: {}", unknownHostException.getMessage());
setConnected(false);
} catch (SocketException socketException) {
logger.error("openConnection(): Socket Exception: {}", socketException.getMessage());
logger.warn("openConnection(): Socket Exception: {}", socketException.getMessage());
setConnected(false);
} catch (IOException ioException) {
logger.error("openConnection(): IO Exception: {}", ioException.getMessage());
logger.warn("openConnection(): IO Exception: {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("openConnection(): Unable to open a connection: {} ", exception.getMessage(), exception);
logger.warn("openConnection(): Unable to open a connection: {} ", exception.getMessage(), exception);
setConnected(false);
}
}
@ -125,10 +125,10 @@ public class EnvisalinkBridgeHandler extends DSCAlarmBaseBridgeHandler {
tcpOutput.write(writeString);
tcpOutput.flush();
} catch (IOException ioException) {
logger.error("write(): {}", ioException.getMessage());
logger.warn("write(): {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("write(): Unable to write to socket: {} ", exception.getMessage(), exception);
logger.warn("write(): Unable to write to socket: {} ", exception.getMessage(), exception);
setConnected(false);
}
}
@ -141,10 +141,10 @@ public class EnvisalinkBridgeHandler extends DSCAlarmBaseBridgeHandler {
message = tcpInput.readLine();
logger.debug("read(): Message Received: {}", message);
} catch (IOException ioException) {
logger.error("read(): IO Exception: {}", ioException.getMessage());
logger.warn("read(): IO Exception: {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("read(): Exception: {} ", exception.getMessage(), exception);
logger.warn("read(): Exception: {} ", exception.getMessage(), exception);
setConnected(false);
}
@ -164,9 +164,9 @@ public class EnvisalinkBridgeHandler extends DSCAlarmBaseBridgeHandler {
setConnected(false);
logger.debug("closeConnection(): Closed TCP Connection!");
} catch (IOException ioException) {
logger.error("closeConnection(): Unable to close connection - {}", ioException.getMessage());
logger.warn("closeConnection(): Unable to close connection - {}", ioException.getMessage());
} catch (Exception exception) {
logger.error("closeConnection(): Error closing connection - {}", exception.getMessage());
logger.warn("closeConnection(): Error closing connection - {}", exception.getMessage());
}
}
@ -198,14 +198,14 @@ public class EnvisalinkBridgeHandler extends DSCAlarmBaseBridgeHandler {
try {
handleIncomingMessage(messageLine);
} catch (Exception e) {
logger.error("TCPListener(): Message not handled by bridge: {}", e.getMessage());
logger.warn("TCPListener(): Message not handled by bridge: {}", e.getMessage());
}
} else {
setConnected(false);
}
}
} catch (Exception e) {
logger.error("TCPListener(): Unable to read message: {} ", e.getMessage(), e);
logger.warn("TCPListener(): Unable to read message: {} ", e.getMessage(), e);
closeConnection();
}
}

View File

@ -85,7 +85,7 @@ public class IT100BridgeHandler extends DSCAlarmBaseBridgeHandler implements Ser
SerialPortIdentifier portIdentifier = serialPortManager.getIdentifier(serialPortName);
if (portIdentifier == null) {
logger.error("openConnection(): No Such Port: {}", serialPort);
logger.warn("openConnection(): No Such Port: {}", serialPort);
setConnected(false);
return;
}
@ -106,18 +106,18 @@ public class IT100BridgeHandler extends DSCAlarmBaseBridgeHandler implements Ser
setConnected(true);
} catch (PortInUseException portInUseException) {
logger.error("openConnection(): Port in Use Exception: {}", portInUseException.getMessage());
logger.warn("openConnection(): Port in Use Exception: {}", portInUseException.getMessage());
setConnected(false);
} catch (UnsupportedCommOperationException unsupportedCommOperationException) {
logger.error("openConnection(): Unsupported Comm Operation Exception: {}",
logger.warn("openConnection(): Unsupported Comm Operation Exception: {}",
unsupportedCommOperationException.getMessage());
setConnected(false);
} catch (UnsupportedEncodingException unsupportedEncodingException) {
logger.error("openConnection(): Unsupported Encoding Exception: {}",
logger.warn("openConnection(): Unsupported Encoding Exception: {}",
unsupportedEncodingException.getMessage());
setConnected(false);
} catch (IOException ioException) {
logger.error("openConnection(): IO Exception: {}", ioException.getMessage());
logger.warn("openConnection(): IO Exception: {}", ioException.getMessage());
setConnected(false);
}
}
@ -129,10 +129,10 @@ public class IT100BridgeHandler extends DSCAlarmBaseBridgeHandler implements Ser
serialOutput.flush();
logger.debug("write(): Message Sent: {}", doNotLog ? "***" : writeString);
} catch (IOException ioException) {
logger.error("write(): {}", ioException.getMessage());
logger.warn("write(): {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("write(): Unable to write to serial port: {} ", exception.getMessage(), exception);
logger.warn("write(): Unable to write to serial port: {} ", exception.getMessage(), exception);
setConnected(false);
}
}
@ -145,10 +145,10 @@ public class IT100BridgeHandler extends DSCAlarmBaseBridgeHandler implements Ser
message = readLine();
logger.debug("read(): Message Received: {}", message);
} catch (IOException ioException) {
logger.error("read(): IO Exception: {} ", ioException.getMessage());
logger.warn("read(): IO Exception: {} ", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("read(): Exception: {} ", exception.getMessage(), exception);
logger.warn("read(): Exception: {} ", exception.getMessage(), exception);
setConnected(false);
}
@ -222,7 +222,7 @@ public class IT100BridgeHandler extends DSCAlarmBaseBridgeHandler implements Ser
String messageLine = serialInput.readLine();
handleIncomingMessage(messageLine);
} catch (IOException ioException) {
logger.error("serialEvent(): IO Exception: {}", ioException.getMessage());
logger.warn("serialEvent(): IO Exception: {}", ioException.getMessage());
}
}
}
@ -238,7 +238,7 @@ public class IT100BridgeHandler extends DSCAlarmBaseBridgeHandler implements Ser
serialPort.addEventListener(serialPortEventListenser);
serialPort.notifyOnDataAvailable(true);
} catch (TooManyListenersException tooManyListenersException) {
logger.error("setSerialEventHandler(): Too Many Listeners Exception: {}",
logger.warn("setSerialEventHandler(): Too Many Listeners Exception: {}",
tooManyListenersException.getMessage());
}
}

View File

@ -111,16 +111,16 @@ public class TCPServerBridgeHandler extends DSCAlarmBaseBridgeHandler {
setConnected(true);
} catch (UnknownHostException unknownHostException) {
logger.error("openConnection(): Unknown Host Exception: {}", unknownHostException.getMessage());
logger.warn("openConnection(): Unknown Host Exception: {}", unknownHostException.getMessage());
setConnected(false);
} catch (SocketException socketException) {
logger.error("openConnection(): Socket Exception: {}", socketException.getMessage());
logger.warn("openConnection(): Socket Exception: {}", socketException.getMessage());
setConnected(false);
} catch (IOException ioException) {
logger.error("openConnection(): IO Exception: {}", ioException.getMessage());
logger.warn("openConnection(): IO Exception: {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("openConnection(): Unable to open a connection: {} ", exception.getMessage(), exception);
logger.warn("openConnection(): Unable to open a connection: {} ", exception.getMessage(), exception);
setConnected(false);
}
}
@ -132,10 +132,10 @@ public class TCPServerBridgeHandler extends DSCAlarmBaseBridgeHandler {
tcpOutput.flush();
logger.debug("write(): Message Sent: {}", doNotLog ? "***" : writeString);
} catch (IOException ioException) {
logger.error("write(): {}", ioException.getMessage());
logger.warn("write(): {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("write(): Unable to write to socket: {} ", exception.getMessage(), exception);
logger.warn("write(): Unable to write to socket: {} ", exception.getMessage(), exception);
setConnected(false);
}
}
@ -148,10 +148,10 @@ public class TCPServerBridgeHandler extends DSCAlarmBaseBridgeHandler {
message = tcpInput.readLine();
logger.debug("read(): Message Received: {}", message);
} catch (IOException ioException) {
logger.error("read(): IO Exception: {}", ioException.getMessage());
logger.warn("read(): IO Exception: {}", ioException.getMessage());
setConnected(false);
} catch (Exception exception) {
logger.error("read(): Exception: {} ", exception.getMessage(), exception);
logger.warn("read(): Exception: {} ", exception.getMessage(), exception);
setConnected(false);
}
@ -170,9 +170,9 @@ public class TCPServerBridgeHandler extends DSCAlarmBaseBridgeHandler {
setConnected(false);
logger.debug("closeConnection(): Closed TCP Connection!");
} catch (IOException ioException) {
logger.error("closeConnection(): Unable to close connection - {}", ioException.getMessage());
logger.warn("closeConnection(): Unable to close connection - {}", ioException.getMessage());
} catch (Exception exception) {
logger.error("closeConnection(): Error closing connection - {}", exception.getMessage());
logger.warn("closeConnection(): Error closing connection - {}", exception.getMessage());
}
}
@ -195,14 +195,14 @@ public class TCPServerBridgeHandler extends DSCAlarmBaseBridgeHandler {
try {
handleIncomingMessage(messageLine);
} catch (Exception e) {
logger.error("TCPListener(): Message not handled by bridge: {}", e.getMessage());
logger.warn("TCPListener(): Message not handled by bridge: {}", e.getMessage());
}
} else {
setConnected(false);
}
}
} catch (Exception e) {
logger.error("TCPListener(): Unable to read message: {} ", e.getMessage(), e);
logger.warn("TCPListener(): Unable to read message: {} ", e.getMessage(), e);
closeConnection();
}
}