Skip to content

Commit

Permalink
[server] Enhance server storage logs (#9886)
Browse files Browse the repository at this point in the history
Currently, applications print lots of "Retrieved value from
server storage" messages on startup, even if the value was
actually not found in the storage. Make sure the logs are
printed only when a value is really loaded, stored or
deleted.
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Oct 1, 2021
1 parent 6acc648 commit f024f16
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,23 @@ class Server : public Messaging::ExchangeDelegate
{
CHIP_ERROR SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) override
{
ChipLogProgress(AppServer, "Retrieved value from server storage.");
return DeviceLayer::PersistedStorage::KeyValueStoreMgr().Get(key, buffer, size);
ReturnErrorOnFailure(DeviceLayer::PersistedStorage::KeyValueStoreMgr().Get(key, buffer, size));
ChipLogProgress(AppServer, "Retrieved from server storage: %s", key);
return CHIP_NO_ERROR;
}

CHIP_ERROR SyncSetKeyValue(const char * key, const void * value, uint16_t size) override
{
ChipLogProgress(AppServer, "Stored value in server storage");
return DeviceLayer::PersistedStorage::KeyValueStoreMgr().Put(key, value, size);
ReturnErrorOnFailure(DeviceLayer::PersistedStorage::KeyValueStoreMgr().Put(key, value, size));
ChipLogProgress(AppServer, "Saved into server storage: %s", key);
return CHIP_NO_ERROR;
}

CHIP_ERROR SyncDeleteKeyValue(const char * key) override
{
ChipLogProgress(AppServer, "Delete value in server storage");
return DeviceLayer::PersistedStorage::KeyValueStoreMgr().Delete(key);
ReturnErrorOnFailure(DeviceLayer::PersistedStorage::KeyValueStoreMgr().Delete(key));
ChipLogProgress(AppServer, "Deleted from server storage: %s", key);
return CHIP_NO_ERROR;
}
};

Expand Down

0 comments on commit f024f16

Please sign in to comment.