Skip to content

Commit

Permalink
openhab#16 Adjust logger usages to not be too verbose
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Oeing <christian.oeing@slashgames.org>
Signed-off-by: Gerd Zanker <gerd.zanker@web.de>
  • Loading branch information
coeing authored and GerdZanker committed Jan 7, 2021
1 parent ff96dc3 commit 1f50584
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean doPairing() {
ContentResponse contentResponse;
try {
String publicCert = getCertFromSslContextFactory();
logger.info("Pairing this Client '{}' with SHC {} using Cert {}", BoschSslUtil.getBoschSHCId(), ipAddress,
logger.debug("Pairing this Client '{}' with SHC {} using Cert {}", BoschSslUtil.getBoschSHCId(), ipAddress,
publicCert);

// JSON Rest content
Expand All @@ -124,7 +124,7 @@ public boolean doPairing() {
logger.info("Pairing successful.");
return true;
} else {
logger.info("Pairing failed with responce status {}.", contentResponse.getStatus());
logger.info("Pairing failed with response status {}.", contentResponse.getStatus());
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class BoschInWallSwitchHandler extends BoschSHCHandler {

public BoschInWallSwitchHandler(Thing thing) {
super(thing);
logger.warn("Creating in-wall: {}", thing.getLabel());
}

@Override
Expand All @@ -55,7 +54,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {

if (bridge != null && config != null) {

logger.info("Handle command for: {} - {}", config.id, command);
logger.debug("Handle command for: {} - {}", config.id, command);
BoschSHCBridgeHandler bridgeHandler = (BoschSHCBridgeHandler) bridge.getHandler();

if (bridgeHandler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void initialize() {
logger.warn("Failed to start Bosch SHC Bridge: {}", e);
}

logger.warn("Initializing Bosch SHC Bridge: {} - HTTP client is: {} - version: 2020-04-05",
logger.debug("Initializing Bosch SHC Bridge: {} - HTTP client is: {} - version: 2020-04-05",
config.ipAddress, this.httpClient);

// check access and pair if necessary
Expand Down Expand Up @@ -127,7 +127,7 @@ public void initialize() {

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.warn("Handle command on bridge: {}", config.ipAddress);
logger.debug("Handle command on bridge: {}", config.ipAddress);
}

/**
Expand All @@ -154,13 +154,11 @@ private Boolean getDevices() {

if (devices != null) {
for (Device d : devices) {
// TODO keeping these as warn for the time being, until we have a better means
// of listing
// devices with their Bosch ID
logger.warn("Found device: name={} id={}", d.name, d.id);
// Write found devices into openhab.log until we have implemented auto discovery
logger.info("Found device: name={} id={}", d.name, d.id);
if (d.deviceSerivceIDs != null) {
for (String s : d.deviceSerivceIDs) {
logger.warn(".... service: " + s);
logger.info(".... service: " + s);
}
}
}
Expand All @@ -184,7 +182,7 @@ private Boolean getDevices() {
* Method is synchronous.
*/
private void subscribe() {
logger.info("Sending subscribe request to Bosch");
logger.debug("Sending subscribe request to Bosch");

String[] params = { "com/bosch/sh/remote/*", null }; // TODO Not sure about the tailing null, copied
// from NodeJs
Expand All @@ -196,7 +194,7 @@ private void subscribe() {
// XXX Maybe we should use a different httpClient here, to avoid a race with
// concurrent use from other
// functions.
logger.info("Subscribe: Sending content: {} - using httpClient {}", str_content, this.httpClient);
logger.debug("Subscribe: Sending content: {} - using httpClient {}", str_content, this.httpClient);

class SubscribeListener extends BufferingResponseListener {
private BoschSHCBridgeHandler bridgeHandler;
Expand Down Expand Up @@ -224,11 +222,11 @@ public void onComplete(@Nullable Result result) {
byte[] responseContent = getContent();
String content = new String(responseContent);

logger.info("Subscribe: response complete: {} - return code: {}", content,
logger.debug("Subscribe: response complete: {} - return code: {}", content,
result.getResponse().getStatus());

SubscribeResult subscribeResult = gson.fromJson(content, SubscribeResult.class);
logger.info("Subscribe: Got subscription ID: {} {}", subscribeResult.getResult(),
logger.debug("Subscribe: Got subscription ID: {} {}", subscribeResult.getResult(),
subscribeResult.getJsonrpc());

bridgeHandler.subscriptionId = subscribeResult.getResult();
Expand Down Expand Up @@ -261,7 +259,7 @@ private void longPoll() {
String subscriptionId = this.subscriptionId;
if (subscriptionId == null) {

logger.info("longPoll: Subscription outdated, requesting .. ");
logger.debug("longPoll: Subscription outdated, requesting .. ");
this.subscribe();
return;
}
Expand Down Expand Up @@ -309,7 +307,7 @@ public void onComplete(@Nullable Result result) {

if (update != null && update.state != null) {

logger.info("Got update for {}", update.deviceId);
logger.debug("Got update for {}", update.deviceId);

Bridge bridge = bridgeHandler.getThing();
boolean handled = false;
Expand All @@ -328,7 +326,7 @@ public void onComplete(@Nullable Result result) {

if (deviceId != null && update.deviceId.equals(deviceId)) {

logger.info("Found child: {} - calling processUpdate with {}", handler,
logger.debug("Found child: {} - calling processUpdate with {}", handler,
update.state);
handler.processUpdate(update.id, update.state);
}
Expand All @@ -341,7 +339,7 @@ public void onComplete(@Nullable Result result) {
}

if (!handled) {
logger.info("Could not find a thing for device ID: {}", update.deviceId);
logger.debug("Could not find a thing for device ID: {}", update.deviceId);
}
}
}
Expand Down Expand Up @@ -413,7 +411,7 @@ private Boolean getRooms() {
.send();

String content = contentResponse.getContentAsString();
logger.info("Response complete: {} - return code: {}", content, contentResponse.getStatus());
logger.debug("Response complete: {} - return code: {}", content, contentResponse.getStatus());

Gson gson = new GsonBuilder().create();
Type collectionType = new TypeToken<ArrayList<Room>>() {
Expand All @@ -423,7 +421,7 @@ private Boolean getRooms() {

if (rooms != null) {
for (Room r : rooms) {
logger.warn("Found room: {}", r.name);
logger.info("Found room: {}", r.name);
}
}

Expand Down Expand Up @@ -473,7 +471,7 @@ private Boolean getRooms() {
String url = "https://" + config.ipAddress + ":8444/smarthome/devices/" + deviceId + "/services/"
+ stateName + "/state";

logger.warn("refreshState: Requesting \"{}\" from Bosch: {} via {}", stateName, deviceId, url);
logger.debug("refreshState: Requesting \"{}\" from Bosch: {} via {}", stateName, deviceId, url);

// GET request
// ----------------------------------------------------------------------------------
Expand All @@ -483,7 +481,7 @@ private Boolean getRooms() {
.header("Accept", "application/json").header("Gateway-ID", "64-DA-A0-02-14-9B").method(GET).send();

String content = contentResponse.getContentAsString();
logger.warn("refreshState: Request complete: [{}] - return code: {}", content, contentResponse.getStatus());
logger.debug("refreshState: Request complete: [{}] - return code: {}", content, contentResponse.getStatus());

// TODO Perhaps we should have only one single gson builder per thing?
Gson gson = new GsonBuilder().create();
Expand Down Expand Up @@ -534,7 +532,7 @@ public void updateSwitchState(Thing thing, String command) {
try {

String boschID = handler.getBoschID();
logger.info("Sending update request to Bosch device {}: update: {}", boschID, command);
logger.debug("Sending update request to Bosch device {}: update: {}", boschID, command);

// PUT request
// ----------------------------------------------------------------------------------
Expand All @@ -559,7 +557,7 @@ public void updateSwitchState(Thing thing, String command) {
.content(new StringContentProvider(str_content)).send();

String content = contentResponse.getContentAsString();
logger.info("Response complete: [{}] - return code: {}", content, contentResponse.getStatus());
logger.debug("Response complete: [{}] - return code: {}", content, contentResponse.getStatus());

} catch (InterruptedException | TimeoutException | ExecutionException e) {
logger.warn("HTTP request failed: {}", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public abstract class BoschSHCHandler extends BaseThingHandler {

public BoschSHCHandler(Thing thing) {
super(thing);
logger.warn("Creating thing: {}", thing.getLabel());
}

public @Nullable String getBoschID() {
Expand All @@ -98,9 +97,7 @@ public BoschSHCHandler(Thing thing) {
*/
@Override
public void initialize() {

this.config = getConfigAs(BoschSHCConfiguration.class);
logger.warn("Initializing thing: {}", this.getBoschID());

// Mark immediately as online - if the bridge is online, the thing is too.
updateStatus(ThingStatus.ONLINE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
protected @Nullable ThingHandler createHandler(Thing thing) {

ThingTypeUID thingTypeUID = thing.getThingTypeUID();
logger.warn("Thing createHandler for thing: {} - {}", thing.getLabel(), thingTypeUID);
logger.debug("Thing createHandler for thing: {} - {}", thing.getLabel(), thingTypeUID);

// XXX Make the names in here consistent - remove the stupid Bosch prefixes.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public KeyStore getKeyStoreAndCreateIfNecessary() {
// Either use a different secret instead of the system password (e.g. OpenHAB UUID?)
// or recreate a new keystore with the different system password again (needs pairing)
keyStore.load(new FileInputStream(file), keystorePassword.toCharArray());
logger.info("Using existing keystore {}", keystorePath);
logger.debug("Using existing keystore {}", keystorePath);
return keyStore;
}
} catch (OperatorCreationException | GeneralSecurityException | IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class BoschTwinguardHandler extends BoschSHCHandler {

public BoschTwinguardHandler(Thing thing) {
super(thing);
logger.warn("Creating Twinguard: {}", thing.getLabel());
}

@Override
Expand All @@ -54,8 +53,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
Bridge bridge = this.getBridge();

if (bridge != null && config != null) {

logger.info("Handle command for: {} - {}", config.id, command);
logger.debug("Handle command for: {} - {}", config.id, command);
BoschSHCBridgeHandler bridgeHandler = (BoschSHCBridgeHandler) bridge.getHandler();

if (bridgeHandler != null) {
Expand Down Expand Up @@ -89,14 +87,14 @@ void updateAirQualityState(TwinguardState state) {

@Override
public void processUpdate(String id, @NonNull JsonElement state) {
logger.warn("Twinguard: received update: {} {}", id, state);
logger.debug("Twinguard: received update: {} {}", id, state);

Gson gson = new Gson();

try {
TwinguardState parsed = gson.fromJson(state, TwinguardState.class);

logger.warn("Parsed switch state of {}: {}", this.getBoschID(), parsed);
logger.debug("Parsed switch state of {}: {}", this.getBoschID(), parsed);
updateAirQualityState(parsed);

} catch (JsonSyntaxException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class MotionDetectorHandler extends BoschSHCHandler {

public MotionDetectorHandler(Thing thing) {
super(thing);
logger.warn("Creating motion detector thing: {}", thing.getLabel());
}

@Override
Expand All @@ -48,7 +47,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {

if (bridge != null && config != null) {

logger.info("Handle command for: {} - {}", config.id, command);
logger.debug("Handle command for: {} - {}", config.id, command);
BoschSHCBridgeHandler bridgeHandler = (BoschSHCBridgeHandler) bridge.getHandler();

if (bridgeHandler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class WindowContactHandler extends BoschSHCHandler {

public WindowContactHandler(Thing thing) {
super(thing);
logger.warn("Creating window contact handler: {}", thing.getLabel());
}

@Override
Expand All @@ -54,7 +53,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {

if (bridge != null && config != null) {

logger.info("Handle command for: {} - {}", config.id, command);
logger.debug("Handle command for: {} - {}", config.id, command);
BoschSHCBridgeHandler bridgeHandler = (BoschSHCBridgeHandler) bridge.getHandler();

if (bridgeHandler != null) {
Expand Down

0 comments on commit 1f50584

Please sign in to comment.