Skip to content

Commit 6d63e8c

Browse files
authored
[dscalarm] Add details in bridge handler error log to help find the problem (openhab#17051)
* [dscalarm] Add details in bridge handler error log to help find the problem Signed-off-by: Jimmy Tanagra <[email protected]>
1 parent b58580a commit 6d63e8c

File tree

7 files changed

+55
-55
lines changed

7 files changed

+55
-55
lines changed

bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/DSCAlarmMessage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void processDSCAlarmMessage() {
9696
data = message.substring(3);
9797
}
9898
} catch (Exception e) {
99-
logger.error("processDSCAlarmMessage(): Error processing message: ({}) ", message, e);
99+
logger.warn("processDSCAlarmMessage(): Error processing message: ({}) ", message, e);
100100
return;
101101
}
102102

bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/discovery/DSCAlarmBridgeDiscovery.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void addEnvisalinkBridge(String ipAddress) {
7171

7272
logger.trace("addBridge(): '{}' was added to inbox.", thingUID);
7373
} catch (Exception e) {
74-
logger.error("addBridge(): Error", e);
74+
logger.warn("addBridge(): Error", e);
7575
}
7676
}
7777
}

bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/discovery/EnvisalinkBridgeDiscovery.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public synchronized void discoverBridge() {
7171
lowIP = convertIPToNumber(subnetInfo.getLowAddress());
7272
highIP = convertIPToNumber(subnetInfo.getHighAddress());
7373
} catch (IllegalArgumentException e) {
74-
logger.error("discoverBridge(): Illegal Argument Exception - {}", e.toString());
74+
logger.warn("discoverBridge(): Illegal Argument Exception - {}", e.toString());
7575
return;
7676
} catch (Exception e) {
77-
logger.error("discoverBridge(): Error - Unable to get Subnet Information! {}", e.toString());
77+
logger.warn("discoverBridge(): Error - Unable to get Subnet Information! {}", e.toString());
7878
return;
7979
}
8080

bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/DSCAlarmBaseBridgeHandler.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public synchronized void polling() {
341341
sendCommand(DSCAlarmCode.StatusReport);
342342
}
343343
} else {
344-
logger.error("Not Connected to the DSC Alarm!");
344+
logger.warn("Not Connected to the DSC Alarm!");
345345
connect();
346346
}
347347
}
@@ -380,7 +380,7 @@ public void checkThings() {
380380
}
381381

382382
} else {
383-
logger.error("checkThings(): Thing handler not found!");
383+
logger.warn("checkThings(): Thing handler not found! Thing: {}", thing.getUID());
384384
}
385385
}
386386
}
@@ -648,7 +648,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
648648
}
649649

650650
if (password == null) {
651-
logger.error("sendCommand(): No password!");
651+
logger.warn("sendCommand(): No password!");
652652
break;
653653
}
654654
data = password;
@@ -669,14 +669,14 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
669669
break;
670670
case CommandOutputControl: /* 020 */
671671
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-8]")) {
672-
logger.error(
672+
logger.warn(
673673
"sendCommand(): Partition number must be a single character string from 1 to 8, it was: {}",
674674
dscAlarmData[0]);
675675
break;
676676
}
677677

678678
if (dscAlarmData[1] == null || !dscAlarmData[1].matches("[1-4]")) {
679-
logger.error(
679+
logger.warn(
680680
"sendCommand(): Output number must be a single character string from 1 to 4, it was: {}",
681681
dscAlarmData[1]);
682682
break;
@@ -693,7 +693,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
693693
case PartitionArmControlStay: /* 031 */
694694
case PartitionArmControlZeroEntryDelay: /* 032 */
695695
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-8]")) {
696-
logger.error(
696+
logger.warn(
697697
"sendCommand(): Partition number must be a single character string from 1 to 8, it was: {}",
698698
dscAlarmData[0]);
699699
break;
@@ -704,14 +704,14 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
704704
case PartitionArmControlWithUserCode: /* 033 */
705705
case PartitionDisarmControl: /* 040 */
706706
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-8]")) {
707-
logger.error(
707+
logger.warn(
708708
"sendCommand(): Partition number must be a single character string from 1 to 8, it was: {}",
709709
dscAlarmData[0]);
710710
break;
711711
}
712712

713713
if (userCode == null || userCode.length() < 4 || userCode.length() > 6) {
714-
logger.error("sendCommand(): User Code is invalid, must be between 4 and 6 chars");
714+
logger.warn("sendCommand(): User Code is invalid, must be between 4 and 6 chars");
715715
break;
716716
}
717717

@@ -732,7 +732,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
732732
case TimeDateBroadcastControl: /* 056 */
733733
case TemperatureBroadcastControl: /* 057 */
734734
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[0-1]")) {
735-
logger.error("sendCommand(): Value must be a single character string of 0 or 1: {}",
735+
logger.warn("sendCommand(): Value must be a single character string of 0 or 1: {}",
736736
dscAlarmData[0]);
737737
break;
738738
}
@@ -741,7 +741,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
741741
break;
742742
case TriggerPanicAlarm: /* 060 */
743743
if (dscAlarmData[0] == null || !dscAlarmData[0].matches("[1-3]")) {
744-
logger.error("sendCommand(): FAPcode must be a single character string from 1 to 3, it was: {}",
744+
logger.warn("sendCommand(): FAPcode must be a single character string from 1 to 3, it was: {}",
745745
dscAlarmData[1]);
746746
break;
747747
}
@@ -752,15 +752,15 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
752752
if (dscAlarmProtocol.equals(DSCAlarmProtocol.ENVISALINK_TPI)) {
753753
if (dscAlarmData[0] == null || dscAlarmData[0].length() != 1
754754
|| !dscAlarmData[0].matches("[0-9]|A|#|\\*")) {
755-
logger.error(
755+
logger.warn(
756756
"sendCommand(): \'keystroke\' must be a single character string from 0 to 9, *, #, or A, it was: {}",
757757
dscAlarmData[0]);
758758
break;
759759
}
760760
} else if (dscAlarmProtocol.equals(DSCAlarmProtocol.IT100_API)) {
761761
if (dscAlarmData[0] == null || dscAlarmData[0].length() != 1
762762
|| !dscAlarmData[0].matches("[0-9]|\\*|#|F|A|P|[a-e]|<|>|=|\\^|L")) {
763-
logger.error(
763+
logger.warn(
764764
"sendCommand(): \'keystroke\' must be a single character string from 0 to 9, *, #, F, A, P, a to e, <, >, =, or ^, it was: {}",
765765
dscAlarmData[0]);
766766
break;
@@ -771,7 +771,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
771771
validCommand = true;
772772
break;
773773
} catch (InterruptedException e) {
774-
logger.error("sendCommand(): \'keystroke\': Error with Long Key Press!");
774+
logger.warn("sendCommand(): \'keystroke\': Error with Long Key Press!");
775775
break;
776776
}
777777
}
@@ -789,7 +789,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
789789

790790
if (dscAlarmData[0] == null || dscAlarmData[0].length() > 6
791791
|| !dscAlarmData[0].matches("(\\d|#|\\*)+")) {
792-
logger.error(
792+
logger.warn(
793793
"sendCommand(): \'keysequence\' must be a string of up to 6 characters consiting of 0 to 9, *, or #, it was: {}",
794794
dscAlarmData[0]);
795795
break;
@@ -799,7 +799,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
799799
break;
800800
case CodeSend: /* 200 */
801801
if (userCode == null || userCode.length() < 4 || userCode.length() > 6) {
802-
logger.error("sendCommand(): Access Code is invalid, must be between 4 and 6 chars");
802+
logger.warn("sendCommand(): Access Code is invalid, must be between 4 and 6 chars");
803803
break;
804804
}
805805

@@ -820,7 +820,7 @@ public boolean sendCommand(DSCAlarmCode dscAlarmCode, String... dscAlarmData) {
820820
successful = true;
821821
logger.debug("sendCommand(): '{}' Command Sent - {}", dscAlarmCode, confidentialData ? "***" : cmd);
822822
} else {
823-
logger.error("sendCommand(): Command '{}' Not Sent - Invalid!", dscAlarmCode);
823+
logger.warn("sendCommand(): Command '{}' Not Sent - Invalid!", dscAlarmCode);
824824
}
825825

826826
return successful;

bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/EnvisalinkBridgeHandler.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ public void openConnection() {
104104

105105
setConnected(true);
106106
} catch (UnknownHostException unknownHostException) {
107-
logger.error("openConnection(): Unknown Host Exception: {}", unknownHostException.getMessage());
107+
logger.warn("openConnection(): Unknown Host Exception: {}", unknownHostException.getMessage());
108108
setConnected(false);
109109
} catch (SocketException socketException) {
110-
logger.error("openConnection(): Socket Exception: {}", socketException.getMessage());
110+
logger.warn("openConnection(): Socket Exception: {}", socketException.getMessage());
111111
setConnected(false);
112112
} catch (IOException ioException) {
113-
logger.error("openConnection(): IO Exception: {}", ioException.getMessage());
113+
logger.warn("openConnection(): IO Exception: {}", ioException.getMessage());
114114
setConnected(false);
115115
} catch (Exception exception) {
116-
logger.error("openConnection(): Unable to open a connection: {} ", exception.getMessage(), exception);
116+
logger.warn("openConnection(): Unable to open a connection: {} ", exception.getMessage(), exception);
117117
setConnected(false);
118118
}
119119
}
@@ -125,10 +125,10 @@ public void write(String writeString, boolean doNotLog) {
125125
tcpOutput.write(writeString);
126126
tcpOutput.flush();
127127
} catch (IOException ioException) {
128-
logger.error("write(): {}", ioException.getMessage());
128+
logger.warn("write(): {}", ioException.getMessage());
129129
setConnected(false);
130130
} catch (Exception exception) {
131-
logger.error("write(): Unable to write to socket: {} ", exception.getMessage(), exception);
131+
logger.warn("write(): Unable to write to socket: {} ", exception.getMessage(), exception);
132132
setConnected(false);
133133
}
134134
}
@@ -141,10 +141,10 @@ public String read() {
141141
message = tcpInput.readLine();
142142
logger.debug("read(): Message Received: {}", message);
143143
} catch (IOException ioException) {
144-
logger.error("read(): IO Exception: {}", ioException.getMessage());
144+
logger.warn("read(): IO Exception: {}", ioException.getMessage());
145145
setConnected(false);
146146
} catch (Exception exception) {
147-
logger.error("read(): Exception: {} ", exception.getMessage(), exception);
147+
logger.warn("read(): Exception: {} ", exception.getMessage(), exception);
148148
setConnected(false);
149149
}
150150

@@ -164,9 +164,9 @@ public void closeConnection() {
164164
setConnected(false);
165165
logger.debug("closeConnection(): Closed TCP Connection!");
166166
} catch (IOException ioException) {
167-
logger.error("closeConnection(): Unable to close connection - {}", ioException.getMessage());
167+
logger.warn("closeConnection(): Unable to close connection - {}", ioException.getMessage());
168168
} catch (Exception exception) {
169-
logger.error("closeConnection(): Error closing connection - {}", exception.getMessage());
169+
logger.warn("closeConnection(): Error closing connection - {}", exception.getMessage());
170170
}
171171
}
172172

@@ -198,14 +198,14 @@ public void run() {
198198
try {
199199
handleIncomingMessage(messageLine);
200200
} catch (Exception e) {
201-
logger.error("TCPListener(): Message not handled by bridge: {}", e.getMessage());
201+
logger.warn("TCPListener(): Message not handled by bridge: {}", e.getMessage());
202202
}
203203
} else {
204204
setConnected(false);
205205
}
206206
}
207207
} catch (Exception e) {
208-
logger.error("TCPListener(): Unable to read message: {} ", e.getMessage(), e);
208+
logger.warn("TCPListener(): Unable to read message: {} ", e.getMessage(), e);
209209
closeConnection();
210210
}
211211
}

bundles/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/handler/IT100BridgeHandler.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void openConnection() {
8585

8686
SerialPortIdentifier portIdentifier = serialPortManager.getIdentifier(serialPortName);
8787
if (portIdentifier == null) {
88-
logger.error("openConnection(): No Such Port: {}", serialPort);
88+
logger.warn("openConnection(): No Such Port: {}", serialPort);
8989
setConnected(false);
9090
return;
9191
}
@@ -106,18 +106,18 @@ public void openConnection() {
106106

107107
setConnected(true);
108108
} catch (PortInUseException portInUseException) {
109-
logger.error("openConnection(): Port in Use Exception: {}", portInUseException.getMessage());
109+
logger.warn("openConnection(): Port in Use Exception: {}", portInUseException.getMessage());
110110
setConnected(false);
111111
} catch (UnsupportedCommOperationException unsupportedCommOperationException) {
112-
logger.error("openConnection(): Unsupported Comm Operation Exception: {}",
112+
logger.warn("openConnection(): Unsupported Comm Operation Exception: {}",
113113
unsupportedCommOperationException.getMessage());
114114
setConnected(false);
115115
} catch (UnsupportedEncodingException unsupportedEncodingException) {
116-
logger.error("openConnection(): Unsupported Encoding Exception: {}",
116+
logger.warn("openConnection(): Unsupported Encoding Exception: {}",
117117
unsupportedEncodingException.getMessage());
118118
setConnected(false);
119119
} catch (IOException ioException) {
120-
logger.error("openConnection(): IO Exception: {}", ioException.getMessage());
120+
logger.warn("openConnection(): IO Exception: {}", ioException.getMessage());
121121
setConnected(false);
122122
}
123123
}
@@ -129,10 +129,10 @@ public void write(String writeString, boolean doNotLog) {
129129
serialOutput.flush();
130130
logger.debug("write(): Message Sent: {}", doNotLog ? "***" : writeString);
131131
} catch (IOException ioException) {
132-
logger.error("write(): {}", ioException.getMessage());
132+
logger.warn("write(): {}", ioException.getMessage());
133133
setConnected(false);
134134
} catch (Exception exception) {
135-
logger.error("write(): Unable to write to serial port: {} ", exception.getMessage(), exception);
135+
logger.warn("write(): Unable to write to serial port: {} ", exception.getMessage(), exception);
136136
setConnected(false);
137137
}
138138
}
@@ -145,10 +145,10 @@ public String read() {
145145
message = readLine();
146146
logger.debug("read(): Message Received: {}", message);
147147
} catch (IOException ioException) {
148-
logger.error("read(): IO Exception: {} ", ioException.getMessage());
148+
logger.warn("read(): IO Exception: {} ", ioException.getMessage());
149149
setConnected(false);
150150
} catch (Exception exception) {
151-
logger.error("read(): Exception: {} ", exception.getMessage(), exception);
151+
logger.warn("read(): Exception: {} ", exception.getMessage(), exception);
152152
setConnected(false);
153153
}
154154

@@ -222,7 +222,7 @@ public synchronized void serialEvent(SerialPortEvent serialPortEvent) {
222222
String messageLine = serialInput.readLine();
223223
handleIncomingMessage(messageLine);
224224
} catch (IOException ioException) {
225-
logger.error("serialEvent(): IO Exception: {}", ioException.getMessage());
225+
logger.warn("serialEvent(): IO Exception: {}", ioException.getMessage());
226226
}
227227
}
228228
}
@@ -238,7 +238,7 @@ private void setSerialEventHandler(SerialPortEventListener serialPortEventListen
238238
serialPort.addEventListener(serialPortEventListenser);
239239
serialPort.notifyOnDataAvailable(true);
240240
} catch (TooManyListenersException tooManyListenersException) {
241-
logger.error("setSerialEventHandler(): Too Many Listeners Exception: {}",
241+
logger.warn("setSerialEventHandler(): Too Many Listeners Exception: {}",
242242
tooManyListenersException.getMessage());
243243
}
244244
}

0 commit comments

Comments
 (0)