diff mbox series

[ovs-dev,v8,2/7] Export `VLOG_WARN` and `VLOG_ERR` from libovn for use in ddlog

Message ID 20201126054844.4005925-3-blp@ovn.org
State Superseded
Headers show
Series Add DDlog implementation of ovn-northd | expand

Commit Message

Ben Pfaff Nov. 26, 2020, 5:48 a.m. UTC
From: Leonid Ryzhyk <lryzhyk@vmware.com>

Export `ddlog_warn` and `ddlog_err` functions that are just wrappers
around `VLOG_WARN` and `VLOG_ERR`.  This is not ideal because the
functions are exported by `ovn_util.c` and the resulting log messages use
`ovn_util` as module name.  More importantly, these functions do not do
log rate limiting.

Signed-off-by: Leonid Ryzhyk <lryzhyk@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
 TODO.rst       |  6 ++++++
 lib/ovn-util.c | 15 +++++++++++++++
 lib/ovn-util.h |  5 +++++
 3 files changed, 26 insertions(+)
diff mbox series


diff --git a/TODO.rst b/TODO.rst
index c15815539f4f..ecfe62870fb0 100644
--- a/TODO.rst
+++ b/TODO.rst
@@ -153,6 +153,12 @@  OVN To-do List
   hashtable lookup in parse_port_group() which can be avoided when we are sure
   that the Southbound DB uses the new format.
+* ovn-northd-ddlog: Calls to warn() and err() from DDlog code would be
+  better refactored to use the Warning[] relation (and introduce an
+  Error[] relation once we want to issue some errors that way).  This
+  would be easier with some improvements in DDlog to more easily
+  output to multiple relations from a single production.
 * IP Multicast Relay
   * When connecting bridged logical switches (localnet) to logical routers
diff --git a/lib/ovn-util.c b/lib/ovn-util.c
index 97d27efa3f20..2606169f0da6 100644
--- a/lib/ovn-util.c
+++ b/lib/ovn-util.c
@@ -734,3 +734,18 @@  ovn_get_internal_version(void)
                      N_OVNACTS, OVN_INTERNAL_MINOR_VER);
+#ifdef DDLOG
+/* Callbacks used by the ddlog northd code to print warnings and errors. */
+ddlog_warn(const char *msg)
+    VLOG_WARN("%s", msg);
+ddlog_err(const char *msg)
+    VLOG_ERR("%s", msg);
diff --git a/lib/ovn-util.h b/lib/ovn-util.h
index 280bcc3e4f6f..5ceeb52cff7b 100644
--- a/lib/ovn-util.h
+++ b/lib/ovn-util.h
@@ -226,4 +226,9 @@  bool ip_address_and_port_from_lb_key(const char *key, char **ip_address,
  * value. */
 char *ovn_get_internal_version(void);
+#ifdef DDLOG
+void ddlog_warn(const char *msg);
+void ddlog_err(const char *msg);