In virtlogd.conf, introduce a new timestamp option.
When set to 1, timestamp is appended after \n in serial console logs.
Signed-off-by: Shaleen Bathla <shaleen.bathla(a)oracle.com>
---
src/logging/log_daemon_config.c | 3 +++
src/logging/log_daemon_config.h | 1 +
src/logging/test_virtlogd.aug.in | 1 +
src/logging/virtlogd.aug | 1 +
src/logging/virtlogd.conf | 4 ++++
5 files changed, 10 insertions(+)
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index 248bd927d3f0..278e4c0a7832 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -62,6 +62,7 @@ virLogDaemonConfigNew(bool privileged G_GNUC_UNUSED)
data->max_size = 1024 * 1024 * 2;
data->max_backups = 3;
data->max_age_days = 0;
+ data->timestamp = 0;
return data;
}
@@ -101,6 +102,8 @@ virLogDaemonConfigLoadOptions(virLogDaemonConfig *data,
return -1;
if (virConfGetValueString(conf, "log_root", &data->log_root) <
0)
return -1;
+ if (virConfGetValueBool(conf, "timestamp", &data->timestamp) <
0)
+ return -1;
if (!data->log_root)
data->log_root = g_strdup(DEFAULT_LOG_ROOT);
diff --git a/src/logging/log_daemon_config.h b/src/logging/log_daemon_config.h
index 43922feedf6e..8fe3ac460cb8 100644
--- a/src/logging/log_daemon_config.h
+++ b/src/logging/log_daemon_config.h
@@ -36,6 +36,7 @@ struct _virLogDaemonConfig {
char *log_root;
size_t max_age_days;
+ bool timestamp;
};
diff --git a/src/logging/test_virtlogd.aug.in b/src/logging/test_virtlogd.aug.in
index 8dfad3950608..dfae4fff15fd 100644
--- a/src/logging/test_virtlogd.aug.in
+++ b/src/logging/test_virtlogd.aug.in
@@ -11,3 +11,4 @@ module Test_virtlogd =
{ "max_backups" = "3" }
{ "max_age_days" = "0" }
{ "log_root" = "/var/log/libvirt" }
+ { "timestamp" = "0" }
diff --git a/src/logging/virtlogd.aug b/src/logging/virtlogd.aug
index bdf61dea6eb5..a1e5c09bbb04 100644
--- a/src/logging/virtlogd.aug
+++ b/src/logging/virtlogd.aug
@@ -33,6 +33,7 @@ module Virtlogd =
| int_entry "max_backups"
| int_entry "max_age_days"
| str_entry "log_root"
+ | bool_entry "timestamp"
(* Each entry in the config is one of the following three ... *)
let entry = logging_entry
diff --git a/src/logging/virtlogd.conf b/src/logging/virtlogd.conf
index 5214e96121a1..2c45f3da2e3d 100644
--- a/src/logging/virtlogd.conf
+++ b/src/logging/virtlogd.conf
@@ -115,3 +115,7 @@
# WARNING: all files under this location potentially can be GC-ed. See the
# warning for max_age_days.
#log_root = "/var/log/libvirt"
+
+# Append timestamp to serial console logs after every '\n' character
+# Defaults to 0 i.e. turned off
+#timestamp = 0
--
2.39.3