diff mbox series

[ovs-dev,v5,1/8] Export `VLOG_WARN` and `VLOG_ERR` from libovn for use in ddlog

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

Commit Message

Ben Pfaff Nov. 12, 2020, 1:45 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>
---
 lib/ovn-util.c | 17 +++++++++++++++++
 lib/ovn-util.h |  6 ++++++
 2 files changed, 23 insertions(+)

Comments

0-day Robot Nov. 12, 2020, 2:01 a.m. UTC | #1
Bleep bloop.  Greetings Ben Pfaff, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Ben Pfaff <blp@ovn.org>
Lines checked: 61, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Dumitru Ceara Nov. 12, 2020, 8:30 a.m. UTC | #2
On 11/12/20 2:45 AM, Ben Pfaff wrote:
> 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.
> 

Should we add a TODO.rst item for this?  I see we use warn() in quite a
few places in the ddlog implementation to report issues caused by user
misconfigs.

> Signed-off-by: Leonid Ryzhyk <lryzhyk@vmware.com>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---
>  lib/ovn-util.c | 17 +++++++++++++++++
>  lib/ovn-util.h |  6 ++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/lib/ovn-util.c b/lib/ovn-util.c
> index 18aac8da34ca..0416f44c79d0 100644
> --- a/lib/ovn-util.c
> +++ b/lib/ovn-util.c
> @@ -713,3 +713,20 @@ ip_address_and_port_from_lb_key(const char *key, char **ip_address,
>      *addr_family = ss.ss_family;
>      return true;
>  }
> +
> +#ifdef DDLOG
> +
> +/* Callbacks used by the ddlog northd code to print warnings and errors.
> + */

The '*/' fits fine on the previous line.

> +void
> +ddlog_warn(const char *msg)
> +{
> +    VLOG_WARN("%s", msg);
> +}
> +
> +void
> +ddlog_err(const char *msg)
> +{
> +    VLOG_ERR("%s", msg);
> +}
> +#endif

Nit: I'd either add a newline before #endif or remove the newline after
#ifdef DDLOG.

> diff --git a/lib/ovn-util.h b/lib/ovn-util.h
> index 3496673b2641..835111872c07 100644
> --- a/lib/ovn-util.h
> +++ b/lib/ovn-util.h
> @@ -221,4 +221,10 @@ char *str_tolower(const char *orig);
>  bool ip_address_and_port_from_lb_key(const char *key, char **ip_address,
>                                       uint16_t *port, int *addr_family);
>  
> +#ifdef DDLOG
> +void ddlog_warn(const char *msg);
> +void ddlog_err(const char *msg);
> +#endif
> +
> +

Nit: I don't think we need the second newline.

Thanks,
Dumitru

>  #endif
>
Ben Pfaff Nov. 12, 2020, 6:04 p.m. UTC | #3
Thanks for the comments!  I made all of these changes and they will be
in v6.

On Thu, Nov 12, 2020 at 09:30:03AM +0100, Dumitru Ceara wrote:
> On 11/12/20 2:45 AM, Ben Pfaff wrote:
> > 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.
> > 
> 
> Should we add a TODO.rst item for this?  I see we use warn() in quite a
> few places in the ddlog implementation to report issues caused by user
> misconfigs.
> 
> > Signed-off-by: Leonid Ryzhyk <lryzhyk@vmware.com>
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> > ---
> >  lib/ovn-util.c | 17 +++++++++++++++++
> >  lib/ovn-util.h |  6 ++++++
> >  2 files changed, 23 insertions(+)
> > 
> > diff --git a/lib/ovn-util.c b/lib/ovn-util.c
> > index 18aac8da34ca..0416f44c79d0 100644
> > --- a/lib/ovn-util.c
> > +++ b/lib/ovn-util.c
> > @@ -713,3 +713,20 @@ ip_address_and_port_from_lb_key(const char *key, char **ip_address,
> >      *addr_family = ss.ss_family;
> >      return true;
> >  }
> > +
> > +#ifdef DDLOG
> > +
> > +/* Callbacks used by the ddlog northd code to print warnings and errors.
> > + */
> 
> The '*/' fits fine on the previous line.
> 
> > +void
> > +ddlog_warn(const char *msg)
> > +{
> > +    VLOG_WARN("%s", msg);
> > +}
> > +
> > +void
> > +ddlog_err(const char *msg)
> > +{
> > +    VLOG_ERR("%s", msg);
> > +}
> > +#endif
> 
> Nit: I'd either add a newline before #endif or remove the newline after
> #ifdef DDLOG.
> 
> > diff --git a/lib/ovn-util.h b/lib/ovn-util.h
> > index 3496673b2641..835111872c07 100644
> > --- a/lib/ovn-util.h
> > +++ b/lib/ovn-util.h
> > @@ -221,4 +221,10 @@ char *str_tolower(const char *orig);
> >  bool ip_address_and_port_from_lb_key(const char *key, char **ip_address,
> >                                       uint16_t *port, int *addr_family);
> >  
> > +#ifdef DDLOG
> > +void ddlog_warn(const char *msg);
> > +void ddlog_err(const char *msg);
> > +#endif
> > +
> > +
> 
> Nit: I don't think we need the second newline.
> 
> Thanks,
> Dumitru
> 
> >  #endif
> > 
>
diff mbox series

Patch

diff --git a/lib/ovn-util.c b/lib/ovn-util.c
index 18aac8da34ca..0416f44c79d0 100644
--- a/lib/ovn-util.c
+++ b/lib/ovn-util.c
@@ -713,3 +713,20 @@  ip_address_and_port_from_lb_key(const char *key, char **ip_address,
     *addr_family = ss.ss_family;
     return true;
 }
+
+#ifdef DDLOG
+
+/* Callbacks used by the ddlog northd code to print warnings and errors.
+ */
+void
+ddlog_warn(const char *msg)
+{
+    VLOG_WARN("%s", msg);
+}
+
+void
+ddlog_err(const char *msg)
+{
+    VLOG_ERR("%s", msg);
+}
+#endif
diff --git a/lib/ovn-util.h b/lib/ovn-util.h
index 3496673b2641..835111872c07 100644
--- a/lib/ovn-util.h
+++ b/lib/ovn-util.h
@@ -221,4 +221,10 @@  char *str_tolower(const char *orig);
 bool ip_address_and_port_from_lb_key(const char *key, char **ip_address,
                                      uint16_t *port, int *addr_family);
 
+#ifdef DDLOG
+void ddlog_warn(const char *msg);
+void ddlog_err(const char *msg);
+#endif
+
+
 #endif