mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
Other: added a few log entries related to gRPC server and client config files.
This commit is contained in:
@ -123,8 +123,7 @@ bool GRPCClient::connectToServer(GRPCConfig const &config, QString &outError)
|
||||
int i = 0;
|
||||
while (true)
|
||||
{
|
||||
if (log_)
|
||||
log_->debug(QString("Connection to gRPC server at %1. attempt #%2").arg(address).arg(++i));
|
||||
this->logDebug(QString("Connection to gRPC server at %1. attempt #%2").arg(address).arg(++i));
|
||||
|
||||
if (channel_->WaitForConnected(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(grpcConnectionRetryDelayMs, GPR_TIMESPAN))))
|
||||
break; // connection established.
|
||||
@ -136,13 +135,13 @@ bool GRPCClient::connectToServer(GRPCConfig const &config, QString &outError)
|
||||
if (channel_->GetState(true) != GRPC_CHANNEL_READY)
|
||||
throw Exception("connection check failed.");
|
||||
|
||||
if (log_)
|
||||
log_->debug("Successfully connected to gRPC server.");
|
||||
this->logDebug("Successfully connected to gRPC server.");
|
||||
|
||||
QString const clientToken = QUuid::createUuid().toString();
|
||||
QString clientConfigPath = createClientConfigFile(clientToken);
|
||||
if (clientConfigPath.isEmpty())
|
||||
throw Exception("gRPC client config could not be saved.");
|
||||
this->logDebug(QString("Client config file was saved to '%1'").arg(QDir::toNativeSeparators(clientConfigPath)));
|
||||
|
||||
QString returnedClientToken;
|
||||
grpc::Status status = this->checkTokens(QDir::toNativeSeparators(clientConfigPath), returnedClientToken);
|
||||
@ -874,8 +873,7 @@ grpc::Status GRPCClient::runEventStreamReader()
|
||||
this->processUserEvent(event.user());
|
||||
break;
|
||||
default:
|
||||
if (log_)
|
||||
log_->debug(QString("Unknown stream event type: %1").arg(event.event_case()));
|
||||
this->logDebug(QString("Unknown stream event type: %1").arg(event.event_case()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -897,13 +895,32 @@ grpc::Status GRPCClient::stopEventStreamReader()
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] level The level of the event.
|
||||
/// \param[in] message The event message.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCClient::log(Log::Level level, QString const &message)
|
||||
{
|
||||
if (log_)
|
||||
log_->addEntry(level, message);
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] message The event message.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCClient::logTrace(QString const &message)
|
||||
{
|
||||
if (log_)
|
||||
log_->trace(message);
|
||||
this->log(Log::Level::Trace, message);
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] message The event message.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCClient::logDebug(QString const &message)
|
||||
{
|
||||
this->log(Log::Level::Debug, message);
|
||||
}
|
||||
|
||||
|
||||
@ -912,8 +929,7 @@ void GRPCClient::logTrace(QString const &message)
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCClient::logError(QString const &message)
|
||||
{
|
||||
if (log_)
|
||||
log_->error(message);
|
||||
this->log(Log::Level::Error, message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -207,8 +207,10 @@ public:
|
||||
grpc::Status stopEventStreamReader(); ///< Stop the event stream.
|
||||
|
||||
private:
|
||||
void logTrace(QString const &message); ///< Log an event.
|
||||
void logError(QString const &message); ///< Log an event.
|
||||
void log(Log::Level level, QString const & message); ///< Log an event.
|
||||
void logTrace(QString const &message); ///< Log a trace event.
|
||||
void logDebug(QString const &message); ///< Log a debug event.
|
||||
void logError(QString const &message); ///< Log an error event.
|
||||
grpc::Status logGRPCCallStatus(grpc::Status const &status, QString const &callName, QList<grpc::StatusCode> allowedErrors = {}); ///< Log the status of a gRPC code.
|
||||
grpc::Status simpleMethod(SimpleMethod method); ///< perform a gRPC call to a bool setter.
|
||||
grpc::Status setBool(BoolSetter setter, bool value); ///< perform a gRPC call to a bool setter.
|
||||
|
||||
Reference in New Issue
Block a user