Log uts information on launch of the session and relay daemon
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Jan 2023 19:11:21 +0000 (14:11 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 5 Jan 2023 20:13:06 +0000 (15:13 -0500)
To make debugging easier, log uts information on launch of the daemons.

Produces an output of the following form when the daemons are launched
in verbose mode:
  DBG1 - 14:30:14.997217006 [Main]: System information: (in log_system_information() at logging-utils.cpp:23)
  DBG1 - 14:30:14.997221139 [Main]:  sysname: `Linux` (in log_system_information() at logging-utils.cpp:24)
  DBG1 - 14:30:14.997227199 [Main]:  nodename: `carbonara` (in log_system_information() at logging-utils.cpp:25)
  DBG1 - 14:30:14.997231284 [Main]:  release: `6.1.1-arch1-1` (in log_system_information() at logging-utils.cpp:26)
  DBG1 - 14:30:14.997235261 [Main]:  version: `#1 SMP PREEMPT_DYNAMIC Wed, 21 Dec 2022 22:27:55 +0000` (in log_system_information() at logging-utils.cpp:27)
  DBG1 - 14:30:14.997240214 [Main]:  machine: `x86_64` (in log_system_information() at logging-utils.cpp:28)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I399fe8a88da8480e617cc33dd6b1dc2723c300c7

src/bin/lttng-sessiond/main.cpp
src/common/Makefile.am
src/common/logging-utils.cpp [new file with mode: 0644]
src/common/logging-utils.hpp [new file with mode: 0644]

index 23136f7c8deab6aa4677d51b9b40908b0c76edfd..5d6e03775bf36cbd519744b3b76b671775272231 100644 (file)
@@ -42,6 +42,8 @@
 #include <common/config/session-config.hpp>
 #include <common/ini-config/ini-config.hpp>
 #include <common/dynamic-buffer.hpp>
+#include <common/logging-utils.hpp>
+
 #include <lttng/event-internal.hpp>
 #include "lttng-sessiond.hpp"
 #include "buffer-registry.hpp"
@@ -1538,6 +1540,7 @@ int main(int argc, char **argv)
 
        sessiond_config_log(&the_config);
        sessiond_uuid_log();
+       lttng::logging::log_system_information(PRINT_DBG);
 
        if (opt_print_version) {
                print_version();
index 66ab77d05d9cf825c61feb7c8edb49d77f85a6e1..522a1ee3248ecc4be8b26cce081c416f56a00e2e 100644 (file)
@@ -89,6 +89,7 @@ libcommon_lgpl_la_SOURCES = \
        kernel-probe.cpp \
        location.cpp \
        locked-reference.hpp \
+       logging-utils.hpp logging-utils.cpp \
        log-level-rule.cpp \
        make-unique.hpp \
        make-unique-wrapper.hpp \
diff --git a/src/common/logging-utils.cpp b/src/common/logging-utils.cpp
new file mode 100644 (file)
index 0000000..a0f307a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2023 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <common/logging-utils.hpp>
+
+#include <sys/utsname.h>
+
+/* Output system information as logging statements. */
+void lttng::logging::log_system_information(lttng_error_level error_level)
+{
+       struct utsname name = {};
+       const int ret = uname(&name);
+
+       if (ret) {
+               PERROR("Failed to get system information using uname()")
+               return;
+       }
+
+       LOG(error_level, "System information:");
+       LOG(error_level, "\tsysname: `%s`", name.sysname);
+       LOG(error_level, "\tnodename: `%s`", name.nodename);
+       LOG(error_level, "\trelease: `%s`", name.release);
+       LOG(error_level, "\tversion: `%s`", name.version);
+       LOG(error_level, "\tmachine: `%s`", name.machine);
+}
diff --git a/src/common/logging-utils.hpp b/src/common/logging-utils.hpp
new file mode 100644 (file)
index 0000000..1bd6c15
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2023 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_LOGGING_UTILS_H
+#define LTTNG_LOGGING_UTILS_H
+
+#include <common/error.hpp>
+
+namespace lttng {
+namespace logging {
+
+/* Output system information as logging statements. */
+void log_system_information(lttng_error_level error_level);
+
+} /* namespace logging */
+} /* namespace lttng */
+
+#endif /* LTTNG_LOGGING_UTILS_H */
This page took 0.028549 seconds and 4 git commands to generate.