From cb871ce4bca66681537c27df8684b0664f5166ce Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Wed, 2 Nov 2022 15:19:04 +0100 Subject: [PATCH] GODT-2016: added more logging of gRPC events at info level. --- .../frontend/bridge-gui/bridge-gui/QMLBackend.cpp | 4 +++- internal/frontend/bridge-gui/bridge-gui/main.cpp | 12 ++++++++---- internal/frontend/grpc/service.go | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp index cbc2a1b1..ed7ad8b2 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp @@ -43,7 +43,9 @@ void QMLBackend::init(GRPCConfig const &serviceConfig) { users_ = new UserList(this); - app().grpc().setLog(&app().log()); + Log& log = app().log(); + log.info(QString("Connecting to gRPC service")); + app().grpc().setLog(&log); this->connectGrpcEvents(); QString error; diff --git a/internal/frontend/bridge-gui/bridge-gui/main.cpp b/internal/frontend/bridge-gui/bridge-gui/main.cpp index 0e4196dc..e6667016 100644 --- a/internal/frontend/bridge-gui/bridge-gui/main.cpp +++ b/internal/frontend/bridge-gui/bridge-gui/main.cpp @@ -80,6 +80,7 @@ Log &initLog() { Log &log = app().log(); log.registerAsQtMessageHandler(); + log.setEchoInConsole(true); return log; } @@ -258,7 +259,6 @@ int main(int argc, char *argv[]) // In attached mode, we do not intercept stderr and stdout of bridge, as we did not launch it ourselves, so we output the log to the console. // When not in attached mode, log entries are forwarded to bridge, which output it on stdout/stderr. bridge-gui's process monitor intercept // these outputs and output them on the command-line. - log.setEchoInConsole(attach); log.setLevel(logLevel); if (!attach) @@ -268,12 +268,16 @@ int main(int argc, char *argv[]) launchBridge(args); } - - log.debug(QString("Server configuration file will be loaded from '%1'").arg(QDir::toNativeSeparators(grpcServerConfigPath()))); + log.info(QString("Retrieving gRPC service configuration from '%1'").arg(QDir::toNativeSeparators(grpcServerConfigPath()))); app().backend().init(GRPCClient::waitAndRetrieveServiceConfig(attach ? 0 : grpcServiceConfigWaitDelayMs)); if (!attach) GRPCClient::removeServiceConfigFile(); - log.debug("Backend was successfully initialized."); + + // gRPC communication is established. From now on, log events will be sent to bridge via gRPC. bridge will write these to file, + // and will output then on console if appropriate. If we are not running in attached mode we intercept bridge stdout & stderr and + // display it in our own output and error, so we only continue to log directly to console if we are running in attached mode. + log.setEchoInConsole(attach); + log.info("Backend was successfully initialized."); QQmlApplicationEngine engine; std::unique_ptr rootComponent(createRootQmlComponent(engine)); diff --git a/internal/frontend/grpc/service.go b/internal/frontend/grpc/service.go index 5f53ef15..ed5c918d 100644 --- a/internal/frontend/grpc/service.go +++ b/internal/frontend/grpc/service.go @@ -125,6 +125,7 @@ func NewService( } func (s *Service) startGRPCServer() { + s.log.Info("Starting gRPC server") tlsConfig, pemCert, err := s.generateTLSConfig() if err != nil { s.log.WithError(err).Panic("Could not generate gRPC TLS config") @@ -148,7 +149,7 @@ func (s *Service) startGRPCServer() { if path, err := s.saveGRPCServerConfigFile(); err != nil { s.log.WithError(err).WithField("path", path).Panic("Could not write gRPC service config file") } else { - s.log.WithField("path", path).Debug("Successfully saved gRPC service config file") + s.log.WithField("path", path).Info("Successfully saved gRPC service config file") } s.log.Info("gRPC server listening at ", s.listener.Addr())