Re: [ovs-dev] [PATCH] tests: Don't log to syslog during tests.

2018-08-14 Thread Ilya Maximets
On 10.08.2018 01:41, Ben Pfaff wrote:
> Thanks.  I folded that in and applied this to master.
> 
> Maybe some of your series is cleanups or improvements.  If so, please
> feel free to re-send those parts of it.

Sure. I'll extract some useful parts and re-send.

Meanwhile, I thought about using same "environment variable" concept
for the default timeout. Please, take a look at this patch-set:

  * https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/351104.html

Best regards, Ilya Maximets.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] tests: Don't log to syslog during tests.

2018-08-09 Thread Ben Pfaff
Thanks.  I folded that in and applied this to master.

Maybe some of your series is cleanups or improvements.  If so, please
feel free to re-send those parts of it.

On Thu, Aug 09, 2018 at 05:02:29PM +0300, Ilya Maximets wrote:
> The patch is good.
> 
> The following incremental needed to make it complete:
> 
> diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py
> index d7a84d8..7d416c3 100644
> --- a/python/ovs/vlog.py
> +++ b/python/ovs/vlog.py
> @@ -305,9 +305,11 @@ class Vlog(object):
>  return
>  
>  logger = logging.getLogger('syslog')
> -# If there is no infrastructure to support python syslog, disable
> -# the logger to avoid repeated errors.
> -if not os.path.exists("/dev/log"):
> +# Disable the logger if there is no infrastructure to support python
> +# syslog (to avoid repeated errors) or if the "null" syslog method
> +# requested by environment.
> +if not os.path.exists("/dev/log") \
> +   or os.environ.get('OVS_SYSLOG_METHOD') == "null":
>  logger.disabled = True
>  return
> 
> 
> With above change, tests leaves the crystal clear syslog.
> 
> Beside that,
> Acked-by: Ilya Maximets 
> 
> On 09.08.2018 02:04, Ben Pfaff wrote:
> > Until now, "make check" generated a huge amount of output to syslog.  This
> > commit suppresses it.
> > 
> > CC: Ilya Maximets 
> > Signed-off-by: Ben Pfaff 
> > ---
> >  NEWS  |  2 ++
> >  lib/automake.mk   |  2 ++
> >  lib/syslog-null.c | 60 
> > +++
> >  lib/syslog-null.h | 22 
> >  lib/vlog.c| 12 +--
> >  lib/vlog.man  |  7 ++-
> >  lib/vlog.xml  | 11 +-
> >  tests/atlocal.in  |  4 
> >  8 files changed, 116 insertions(+), 4 deletions(-)
> >  create mode 100644 lib/syslog-null.c
> >  create mode 100644 lib/syslog-null.h
> > 
> > diff --git a/NEWS b/NEWS
> > index 7875f6673e34..ae21340e9046 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -1,5 +1,7 @@
> >  Post-v2.10.0
> >  -
> > +   - The environment variable OVS_SYSLOG_METHOD, if set, is now used
> > + as the default syslog method.
> >  
> >  
> >  v2.10.0 - xx xxx 
> > diff --git a/lib/automake.mk b/lib/automake.mk
> > index fb43aa1413b2..63e9d72ac18a 100644
> > --- a/lib/automake.mk
> > +++ b/lib/automake.mk
> > @@ -280,6 +280,8 @@ lib_libopenvswitch_la_SOURCES = \
> > lib/syslog-direct.h \
> > lib/syslog-libc.c \
> > lib/syslog-libc.h \
> > +   lib/syslog-null.c \
> > +   lib/syslog-null.h \
> > lib/syslog-provider.h \
> > lib/table.c \
> > lib/table.h \
> > diff --git a/lib/syslog-null.c b/lib/syslog-null.c
> > new file mode 100644
> > index ..9dbd13911c21
> > --- /dev/null
> > +++ b/lib/syslog-null.c
> > @@ -0,0 +1,60 @@
> > +/*
> > + * Copyright (c) 2015, 2016 Nicira, Inc.
> > + *
> > + * Licensed under the Apache License, Version 2.0 (the "License");
> > + * you may not use this file except in compliance with the License.
> > + * You may obtain a copy of the License at:
> > + *
> > + * http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +#include "syslog-null.h"
> > +
> > +#include 
> > +
> > +#include "compiler.h"
> > +#include "syslog-provider.h"
> > +#include "util.h"
> > +
> > +static void syslog_null_open(struct syslogger *this, int facility);
> > +static void syslog_null_log(struct syslogger *this, int pri, const char 
> > *msg);
> > +
> > +static struct syslog_class syslog_null_class = {
> > +syslog_null_open,
> > +syslog_null_log,
> > +};
> > +
> > +struct syslog_null {
> > +struct syslogger parent;
> > +};
> > +
> > +/* This function  creates object that delegate all logging to null's
> > + * syslog implementation. */
> > +struct syslogger *
> > +syslog_null_create(void)
> > +{
> > +struct syslog_null *this = xmalloc(sizeof *this);
> > +
> > +this->parent.class = &syslog_null_class;
> > +this->parent.prefix = "";
> > +
> > +return &this->parent;
> > +}
> > +
> > +static void
> > +syslog_null_open(struct syslogger *this OVS_UNUSED, int facility 
> > OVS_UNUSED)
> > +{
> > +/* Nothing to do. */
> > +}
> > +
> > +static void
> > +syslog_null_log(struct syslogger *this OVS_UNUSED, int pri OVS_UNUSED,
> > +const char *msg OVS_UNUSED)
> > +{
> > +/* Nothing to do. */
> > +}
> > diff --git a/lib/syslog-null.h b/lib/syslog-null.h
> > new file mode 100644
> > index ..0f7731dc4dcc
> > --- /dev/null
> > +++ b/lib/syslog-null.h
> > @@ -0,0 +1,22 @@
> > +/*
> > + * Copyright (c) 2015 Nicira, In

Re: [ovs-dev] [PATCH] tests: Don't log to syslog during tests.

2018-08-09 Thread Ilya Maximets
The patch is good.

The following incremental needed to make it complete:

diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py
index d7a84d8..7d416c3 100644
--- a/python/ovs/vlog.py
+++ b/python/ovs/vlog.py
@@ -305,9 +305,11 @@ class Vlog(object):
 return
 
 logger = logging.getLogger('syslog')
-# If there is no infrastructure to support python syslog, disable
-# the logger to avoid repeated errors.
-if not os.path.exists("/dev/log"):
+# Disable the logger if there is no infrastructure to support python
+# syslog (to avoid repeated errors) or if the "null" syslog method
+# requested by environment.
+if not os.path.exists("/dev/log") \
+   or os.environ.get('OVS_SYSLOG_METHOD') == "null":
 logger.disabled = True
 return


With above change, tests leaves the crystal clear syslog.

Beside that,
Acked-by: Ilya Maximets 

On 09.08.2018 02:04, Ben Pfaff wrote:
> Until now, "make check" generated a huge amount of output to syslog.  This
> commit suppresses it.
> 
> CC: Ilya Maximets 
> Signed-off-by: Ben Pfaff 
> ---
>  NEWS  |  2 ++
>  lib/automake.mk   |  2 ++
>  lib/syslog-null.c | 60 
> +++
>  lib/syslog-null.h | 22 
>  lib/vlog.c| 12 +--
>  lib/vlog.man  |  7 ++-
>  lib/vlog.xml  | 11 +-
>  tests/atlocal.in  |  4 
>  8 files changed, 116 insertions(+), 4 deletions(-)
>  create mode 100644 lib/syslog-null.c
>  create mode 100644 lib/syslog-null.h
> 
> diff --git a/NEWS b/NEWS
> index 7875f6673e34..ae21340e9046 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,5 +1,7 @@
>  Post-v2.10.0
>  -
> +   - The environment variable OVS_SYSLOG_METHOD, if set, is now used
> + as the default syslog method.
>  
>  
>  v2.10.0 - xx xxx 
> diff --git a/lib/automake.mk b/lib/automake.mk
> index fb43aa1413b2..63e9d72ac18a 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -280,6 +280,8 @@ lib_libopenvswitch_la_SOURCES = \
>   lib/syslog-direct.h \
>   lib/syslog-libc.c \
>   lib/syslog-libc.h \
> + lib/syslog-null.c \
> + lib/syslog-null.h \
>   lib/syslog-provider.h \
>   lib/table.c \
>   lib/table.h \
> diff --git a/lib/syslog-null.c b/lib/syslog-null.c
> new file mode 100644
> index ..9dbd13911c21
> --- /dev/null
> +++ b/lib/syslog-null.c
> @@ -0,0 +1,60 @@
> +/*
> + * Copyright (c) 2015, 2016 Nicira, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at:
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +#include "syslog-null.h"
> +
> +#include 
> +
> +#include "compiler.h"
> +#include "syslog-provider.h"
> +#include "util.h"
> +
> +static void syslog_null_open(struct syslogger *this, int facility);
> +static void syslog_null_log(struct syslogger *this, int pri, const char 
> *msg);
> +
> +static struct syslog_class syslog_null_class = {
> +syslog_null_open,
> +syslog_null_log,
> +};
> +
> +struct syslog_null {
> +struct syslogger parent;
> +};
> +
> +/* This function  creates object that delegate all logging to null's
> + * syslog implementation. */
> +struct syslogger *
> +syslog_null_create(void)
> +{
> +struct syslog_null *this = xmalloc(sizeof *this);
> +
> +this->parent.class = &syslog_null_class;
> +this->parent.prefix = "";
> +
> +return &this->parent;
> +}
> +
> +static void
> +syslog_null_open(struct syslogger *this OVS_UNUSED, int facility OVS_UNUSED)
> +{
> +/* Nothing to do. */
> +}
> +
> +static void
> +syslog_null_log(struct syslogger *this OVS_UNUSED, int pri OVS_UNUSED,
> +const char *msg OVS_UNUSED)
> +{
> +/* Nothing to do. */
> +}
> diff --git a/lib/syslog-null.h b/lib/syslog-null.h
> new file mode 100644
> index ..0f7731dc4dcc
> --- /dev/null
> +++ b/lib/syslog-null.h
> @@ -0,0 +1,22 @@
> +/*
> + * Copyright (c) 2015 Nicira, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at:
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the

[ovs-dev] [PATCH] tests: Don't log to syslog during tests.

2018-08-08 Thread Ben Pfaff
Until now, "make check" generated a huge amount of output to syslog.  This
commit suppresses it.

CC: Ilya Maximets 
Signed-off-by: Ben Pfaff 
---
 NEWS  |  2 ++
 lib/automake.mk   |  2 ++
 lib/syslog-null.c | 60 +++
 lib/syslog-null.h | 22 
 lib/vlog.c| 12 +--
 lib/vlog.man  |  7 ++-
 lib/vlog.xml  | 11 +-
 tests/atlocal.in  |  4 
 8 files changed, 116 insertions(+), 4 deletions(-)
 create mode 100644 lib/syslog-null.c
 create mode 100644 lib/syslog-null.h

diff --git a/NEWS b/NEWS
index 7875f6673e34..ae21340e9046 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 Post-v2.10.0
 -
+   - The environment variable OVS_SYSLOG_METHOD, if set, is now used
+ as the default syslog method.
 
 
 v2.10.0 - xx xxx 
diff --git a/lib/automake.mk b/lib/automake.mk
index fb43aa1413b2..63e9d72ac18a 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -280,6 +280,8 @@ lib_libopenvswitch_la_SOURCES = \
lib/syslog-direct.h \
lib/syslog-libc.c \
lib/syslog-libc.h \
+   lib/syslog-null.c \
+   lib/syslog-null.h \
lib/syslog-provider.h \
lib/table.c \
lib/table.h \
diff --git a/lib/syslog-null.c b/lib/syslog-null.c
new file mode 100644
index ..9dbd13911c21
--- /dev/null
+++ b/lib/syslog-null.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, 2016 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "syslog-null.h"
+
+#include 
+
+#include "compiler.h"
+#include "syslog-provider.h"
+#include "util.h"
+
+static void syslog_null_open(struct syslogger *this, int facility);
+static void syslog_null_log(struct syslogger *this, int pri, const char *msg);
+
+static struct syslog_class syslog_null_class = {
+syslog_null_open,
+syslog_null_log,
+};
+
+struct syslog_null {
+struct syslogger parent;
+};
+
+/* This function  creates object that delegate all logging to null's
+ * syslog implementation. */
+struct syslogger *
+syslog_null_create(void)
+{
+struct syslog_null *this = xmalloc(sizeof *this);
+
+this->parent.class = &syslog_null_class;
+this->parent.prefix = "";
+
+return &this->parent;
+}
+
+static void
+syslog_null_open(struct syslogger *this OVS_UNUSED, int facility OVS_UNUSED)
+{
+/* Nothing to do. */
+}
+
+static void
+syslog_null_log(struct syslogger *this OVS_UNUSED, int pri OVS_UNUSED,
+const char *msg OVS_UNUSED)
+{
+/* Nothing to do. */
+}
diff --git a/lib/syslog-null.h b/lib/syslog-null.h
new file mode 100644
index ..0f7731dc4dcc
--- /dev/null
+++ b/lib/syslog-null.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYSLOG_NULL_H
+#define SYSLOG_NULL_H 1
+
+struct syslogger *syslog_null_create(void);
+
+#endif /* syslog-null.h */
diff --git a/lib/vlog.c b/lib/vlog.c
index bf5fd88ba9e8..01cfdc5d3d2d 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -39,6 +39,7 @@
 #include "svec.h"
 #include "syslog-direct.h"
 #include "syslog-libc.h"
+#include "syslog-null.h"
 #include "syslog-provider.h"
 #include "timeval.h"
 #include "unixctl.h"
@@ -584,7 +585,9 @@ vlog_set_syslog_method(const char *method)
 return;
 }
 
-if (!strcmp(method, "libc")) {
+if (!strcmp(method, "null")) {
+syslogger = syslog_null_create();
+} else if (!strcmp(method, "libc")) {
 syslogger = syslog_libc_create();
 } else if (!strncmp(method, "udp:", 4) || !strncmp(method, "unix:", 5)) {
 syslogger = syslog_direct_create(method);
@@ -778,7 +781,12 @@ vlog_init(void)
  * log anything before calling ovsthread_once_done() will deadlock. */
 atomic_read_explicit(&log_facility, &facility, memory_order_relaxed);
 if (!syslogger) {
-syslogger = syslog_libc_create();
+char *env = geten