diff mbox series

[ovs-dev,04/13] log: Log write errors.

Message ID 20171208001240.25829-5-blp@ovn.org
State Accepted
Headers show
Series OVSDB log enhancements | expand

Commit Message

Ben Pfaff Dec. 8, 2017, 12:12 a.m. UTC
This saves all the callers from logging them separately.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ovsdb/log.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Justin Pettit Dec. 23, 2017, 4:13 a.m. UTC | #1
> On Dec 7, 2017, at 4:12 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> This saves all the callers from logging them separately.
> 
> Signed-off-by: Ben Pfaff <blp@ovn.org>

Acked-by: Justin Pettit <jpettit@ovn.org>

--Justin
diff mbox series

Patch

diff --git a/ovsdb/log.c b/ovsdb/log.c
index 1a372d7b73ee..f3c6e22ae212 100644
--- a/ovsdb/log.c
+++ b/ovsdb/log.c
@@ -25,6 +25,7 @@ 
 #include <unistd.h>
 
 #include "openvswitch/json.h"
+#include "openvswitch/vlog.h"
 #include "lockfile.h"
 #include "ovsdb.h"
 #include "ovsdb-error.h"
@@ -33,6 +34,8 @@ 
 #include "transaction.h"
 #include "util.h"
 
+VLOG_DEFINE_THIS_MODULE(ovsdb_log);
+
 enum ovsdb_log_mode {
     OVSDB_LOG_READ,
     OVSDB_LOG_WRITE
@@ -411,6 +414,10 @@  ovsdb_log_write(struct ovsdb_log *file, const struct json *json)
     {
         error = ovsdb_io_error(errno, "%s: write failed", file->name);
 
+        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
+        VLOG_WARN_RL(&rl, "%s: write failed (%s)",
+                     file->name, ovs_strerror(errno));
+
         /* Remove any partially written data, ignoring errors since there is
          * nothing further we can do. */
         ignore(ftruncate(fileno(file->stream), file->offset));