]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timesyncd: add address type information to debug log
authorDaniel Mack <daniel@zonque.org>
Thu, 24 Feb 2022 16:47:49 +0000 (17:47 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 9 Apr 2022 01:23:14 +0000 (10:23 +0900)
When looking at debug logs, it's helpful to know what type of server
address has been added.

For that, introduce a string lookup table for the ServerType type.

src/timesync/timesyncd-server.c
src/timesync/timesyncd-server.h

index 002a6117cc2bb81cc36780a88e83281f96907a89..c8ff46f3992e3399f6d63f817d3863ca8677550f 100644 (file)
@@ -1,8 +1,18 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "alloc-util.h"
+#include "string-table.h"
 #include "timesyncd-server.h"
 
+static const char * const server_type_table[_SERVER_TYPE_MAX] = {
+        [SERVER_SYSTEM]   = "system",
+        [SERVER_FALLBACK] = "fallback",
+        [SERVER_LINK]     = "link",
+        [SERVER_RUNTIME]  = "runtime",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(server_type, ServerType);
+
 int server_address_new(
                 ServerName *n,
                 ServerAddress **ret,
@@ -96,7 +106,7 @@ int server_name_new(
             m->current_server_name->type == SERVER_FALLBACK)
                 manager_set_server_name(m, NULL);
 
-        log_debug("Added new server %s.", string);
+        log_debug("Added new %s server %s.", server_type_to_string(type), string);
 
         if (ret)
                 *ret = n;
index ca994bf6ae3648b6919bf435cf82aec3bd8e7ca3..e22917aa12914fa0f7826ab4a88c1cef10a958c4 100644 (file)
@@ -12,6 +12,8 @@ typedef enum ServerType {
         SERVER_FALLBACK,
         SERVER_LINK,
         SERVER_RUNTIME,
+        _SERVER_TYPE_MAX,
+        _SERVER_TYPE_INVALID = -EINVAL,
 } ServerType;
 
 #include "timesyncd-manager.h"