From: Jérémie Galarneau Date: Tue, 3 Jan 2023 19:11:21 +0000 (-0500) Subject: Log uts information on launch of the session and relay daemon X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=e35e95ea77196e8997a02eda4bb8c1c5c6cba0fb Log uts information on launch of the session and relay daemon 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 Change-Id: I399fe8a88da8480e617cc33dd6b1dc2723c300c7 --- diff --git a/src/bin/lttng-sessiond/main.cpp b/src/bin/lttng-sessiond/main.cpp index 23136f7c8..5d6e03775 100644 --- a/src/bin/lttng-sessiond/main.cpp +++ b/src/bin/lttng-sessiond/main.cpp @@ -42,6 +42,8 @@ #include #include #include +#include + #include #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(); diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 66ab77d05..522a1ee32 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 index 000000000..a0f307ad3 --- /dev/null +++ b/src/common/logging-utils.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2023 Jérémie Galarneau + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#include + +#include + +/* 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 index 000000000..1bd6c1552 --- /dev/null +++ b/src/common/logging-utils.hpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 Jérémie Galarneau + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#ifndef LTTNG_LOGGING_UTILS_H +#define LTTNG_LOGGING_UTILS_H + +#include + +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 */