feat(GODT-2705): added log entries for focus service on client and server sides.

This commit is contained in:
Xavier Michelon
2023-06-22 11:19:20 +02:00
committed by Xavier Michelon
parent ab70e85f1c
commit ae65385c38
4 changed files with 24 additions and 7 deletions

View File

@ -46,6 +46,15 @@ QString grpcFocusServerConfigFilename() {
}
//****************************************************************************************************************************************************
/// \param[in] log The log.
//****************************************************************************************************************************************************
FocusGRPCClient::FocusGRPCClient(Log& log)
:log_(log) {
}
//****************************************************************************************************************************************************
/// \return The absolute path of the focus service config path.
//****************************************************************************************************************************************************
@ -91,6 +100,7 @@ bool FocusGRPCClient::connectToServer(qint64 timeoutMs, quint16 port, QString *o
throw Exception("Connexion check with focus service failed.");
}
log_.debug(QString("Successfully connected to focus gRPC service."));
return true;
}
catch (Exception const &e) {
@ -106,6 +116,7 @@ bool FocusGRPCClient::connectToServer(qint64 timeoutMs, quint16 port, QString *o
/// \return The status for the call.
//****************************************************************************************************************************************************
grpc::Status FocusGRPCClient::raise() {
log_.debug("FocusGRPCService::raise()");
ClientContext ctx;
return stub_->Raise(&ctx, empty, &empty);
}
@ -116,6 +127,7 @@ grpc::Status FocusGRPCClient::raise() {
/// \return The status for the call.
//****************************************************************************************************************************************************
grpc::Status FocusGRPCClient::version(QString &outVersion) {
log_.debug("FocusGRPCService::version()");
ClientContext ctx;
VersionResponse response;
Status status = stub_->Version(&ctx, empty, &response);

View File

@ -22,6 +22,7 @@
#include "grpc++/grpc++.h"
#include "focus.grpc.pb.h"
#include "../Log/Log.h"
namespace bridgepp {
@ -36,7 +37,7 @@ public: // static member functions
static QString grpcFocusServerConfigPath(QString const &configDir); ///< Return the path of the gRPC Focus server config file.
public: // member functions.
FocusGRPCClient() = default; ///< Default constructor.
FocusGRPCClient(Log& log); ///< Default constructor.
FocusGRPCClient(FocusGRPCClient const &) = delete; ///< Disabled copy-constructor.
FocusGRPCClient(FocusGRPCClient &&) = delete; ///< Disabled assignment copy-constructor.
~FocusGRPCClient() = default; ///< Destructor.
@ -48,6 +49,7 @@ public: // member functions.
grpc::Status version(QString &outVersion); ///< Performs the 'version' call.
private:
Log &log_; ///< The log to use for logging calls
std::shared_ptr<grpc::Channel> channel_ { nullptr }; ///< The gRPC channel.
std::shared_ptr<focus::Focus::Stub> stub_ { nullptr }; ///< The gRPC stub (a.k.a. client).
};