vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.
authorBen Pfaff <blp@nicira.com>
Fri, 16 Jul 2010 18:02:49 +0000 (11:02 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 21 Jul 2010 22:47:09 +0000 (15:47 -0700)
Adding a macro to define the vlog module in use adds a level of
indirection, which makes it easier to change how the vlog module must be
defined.  A followup commit needs to do that, so getting these widespread
changes out of the way first should make that commit easier to review.

78 files changed:
extras/ezio/ezio-term.c
extras/ezio/ovs-switchui.c
extras/ezio/terminal.c
extras/ezio/tty.c
extras/ezio/vt-dummy.c
extras/ezio/vt-linux.c
lib/automake.mk
lib/backtrace.c
lib/coverage.c
lib/daemon.c
lib/dhcp-client.c
lib/dhcp.c
lib/dpif-linux.c
lib/dpif-netdev.c
lib/dpif.c
lib/fatal-signal.c
lib/flow.c
lib/jsonrpc.c
lib/leak-checker.c
lib/learning-switch.c
lib/lockfile.c
lib/mac-learning.c
lib/netdev-gre.c
lib/netdev-linux.c
lib/netdev-patch.c
lib/netdev-vport.c
lib/netdev.c
lib/netlink.c
lib/ofp-util.c
lib/ovsdb-error.c
lib/ovsdb-idl.c
lib/pcap.c
lib/poll-loop.c
lib/process.c
lib/rconn.c
lib/reconnect.c
lib/rtnetlink.c
lib/socket-util.c
lib/stp.c
lib/stream-fd.c
lib/stream-ssl.c
lib/stream-tcp.c
lib/stream-unix.c
lib/stream.c
lib/svec.c
lib/timeval.c
lib/unixctl.c
lib/util.c
lib/vconn-stream.c
lib/vconn.c
lib/vlog.c
lib/vlog.h
ofproto/collectors.c
ofproto/discovery.c
ofproto/fail-open.c
ofproto/in-band.c
ofproto/netflow.c
ofproto/ofproto-sflow.c
ofproto/ofproto.c
ofproto/pktbuf.c
ofproto/status.c
ovsdb/file.c
ovsdb/jsonrpc-server.c
ovsdb/log.c
ovsdb/ovsdb-client.c
ovsdb/ovsdb-server.c
ovsdb/ovsdb-tool.c
utilities/ovs-controller.c
utilities/ovs-discover.c
utilities/ovs-dpctl.c
utilities/ovs-ofctl.c
utilities/ovs-openflowd.c
utilities/ovs-vsctl.c
vswitchd/bridge.c
vswitchd/ovs-brcompatd.c
vswitchd/ovs-vswitchd.c
vswitchd/proc-net-compat.c
vswitchd/xenserver.c

index f764552..b41a7c0 100644 (file)
 #include "terminal.h"
 #include "timeval.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_ezio_term
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(ezio_term)
+
 /* EZIO button status. */
 enum btn_status {
     BTN_UP    = 1 << 0,
index b1ba8d2..092eb1e 100644 (file)
 #include "timeval.h"
 #include "util.h"
 #include "vconn.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#define THIS_MODULE VLM_switchui
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(switchui)
 
 static void parse_options(int argc, char *argv[]);
 static void usage(void);
index 090e80e..3e499ab 100644 (file)
 #include "ezio.h"
 #include "poll-loop.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_terminal
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(terminal)
+
 /* UTF-8 decoding. */
 static struct utf8_reader *utf8_reader_create(void);
 static void utf8_reader_destroy(struct utf8_reader *);
index 4328828..a4bb14c 100644 (file)
 #include "fatal-signal.h"
 #include "socket-util.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_tty
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(tty)
+
 /* Get major() and minor() macros. */
 #if MAJOR_IN_MKDEV
 #  include <sys/mkdev.h>
index c1de6c8..18da821 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2009 Nicira Networks, Inc.
+/* Copyright (c) 2008, 2009, 2010 Nicira Networks, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <config.h>
 #include "extras/ezio/vt.h"
 #include <errno.h>
-
-#define THIS_MODULE VLM_vt
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(vt)
+
 int
 vt_open(int open_flags)
 {
index 92f7ebb..b281c89 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2009 Nicira Networks, Inc.
+/* Copyright (c) 2008, 2009, 2010 Nicira Networks, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include "util.h"
-
-#define THIS_MODULE VLM_vt
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(vt)
+
 static bool get_console_fd(int *fd);
 
 int
index 71e4d61..046e9ab 100644 (file)
@@ -274,8 +274,8 @@ check-for-unused-vlog-modules:
                     lib/vlog-modules.def |                                   \
                      LC_ALL=C sort -u |                                              \
                      xargs echo`;                                            \
-         used_vlog=`git grep VLM_ |                                          \
-                    sed -n 's/.*VLM_\([a-z_0-9]\{1,\}\).*/\1/p' |            \
+         used_vlog=`git grep VLOG_DEFINE_THIS_MODULE |                       \
+                    sed -n 's/.*VLOG_DEFINE_THIS_MODULE(\([a-z_0-9]\{1,\}\)).*/\1/p' |       \
                     LC_ALL=C sort -u |                                       \
                      xargs echo`;                                            \
          rc=0;                                                               \
index 80cae54..131bdf4 100644 (file)
 #include <stdbool.h>
 #include <stdio.h>
 #include "compiler.h"
-
-#define THIS_MODULE VLM_backtrace
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(backtrace)
+
 static uintptr_t OVS_UNUSED
 get_max_stack(void)
 {
index 5c99c18..6e65810 100644 (file)
 #include "hash.h"
 #include "unixctl.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_coverage
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(coverage)
+
 static unsigned int epoch;
 
 static void
index 59628f2..6cb553a 100644 (file)
 #include "socket-util.h"
 #include "timeval.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_daemon
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(daemon)
+
 /* Should we run in the background? */
 static bool detach;
 
index 7168361..961994a 100644 (file)
 #include "poll-loop.h"
 #include "sat-math.h"
 #include "timeval.h"
-
-#define THIS_MODULE VLM_dhcp_client
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(dhcp_client)
+
 #define DHCLIENT_STATES                         \
     DHCLIENT_STATE(INIT, 1 << 0)                \
     DHCLIENT_STATE(INIT_REBOOT, 1 << 1)         \
index e16176b..e6d5735 100644 (file)
 #include <stdlib.h>
 #include "dynamic-string.h"
 #include "ofpbuf.h"
-
-#define THIS_MODULE VLM_dhcp
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(dhcp)
+
 /* Information about a DHCP argument type. */
 struct arg_type {
     const char *name;           /* Name. */
index 432d5ed..52d73c6 100644 (file)
@@ -41,9 +41,9 @@
 #include "shash.h"
 #include "svec.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_dpif_linux
+
+VLOG_DEFINE_THIS_MODULE(dpif_linux)
 
 /* Datapath interface for the openvswitch Linux kernel module. */
 struct dpif_linux {
index fc117d2..15ff0d5 100644 (file)
@@ -45,9 +45,9 @@
 #include "queue.h"
 #include "timeval.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_dpif_netdev
+
+VLOG_DEFINE_THIS_MODULE(dpif_netdev)
 
 /* Configuration parameters. */
 enum { N_QUEUES = 2 };          /* Number of queues for dpif_recv(). */
index ef28ea9..40741a4 100644 (file)
@@ -37,9 +37,9 @@
 #include "svec.h"
 #include "util.h"
 #include "valgrind.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_dpif
+
+VLOG_DEFINE_THIS_MODULE(dpif)
 
 static const struct dpif_class *base_dpif_classes[] = {
 #ifdef HAVE_NETLINK
index 0f36036..d9442a3 100644 (file)
 #include "shash.h"
 #include "socket-util.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_fatal_signal
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(fatal_signal)
+
 /* Signals to catch. */
 static const int fatal_signals[] = { SIGTERM, SIGINT, SIGHUP, SIGALRM };
 
index 7ae90d2..490c46b 100644 (file)
 #include "openvswitch/datapath-protocol.h"
 #include "packets.h"
 #include "unaligned.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#include "vlog.h"
-#define THIS_MODULE VLM_flow
+VLOG_DEFINE_THIS_MODULE(flow)
 
 static struct arp_eth_header *
 pull_arp(struct ofpbuf *packet)
index 32d34b4..5d394c6 100644 (file)
@@ -32,9 +32,9 @@
 #include "reconnect.h"
 #include "stream.h"
 #include "timeval.h"
-
-#define THIS_MODULE VLM_jsonrpc
 #include "vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(jsonrpc)
 \f
 struct jsonrpc {
     struct stream *stream;
index 4ab55e5..28beb0b 100644 (file)
 #include "leak-checker.h"
 #include <inttypes.h>
 #include "backtrace.h"
-
-#define THIS_MODULE VLM_leak_checker
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(leak_checker)
+
 #ifndef HAVE_MALLOC_HOOKS
 void
 leak_checker_start(const char *file_name OVS_UNUSED)
index 97c424a..d2da252 100644 (file)
 #include "stp.h"
 #include "timeval.h"
 #include "vconn.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#define THIS_MODULE VLM_learning_switch
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(learning_switch)
 
 enum port_state {
     P_DISABLED = 1 << 0,
index 100440e..84bfb3c 100644 (file)
 #include "hmap.h"
 #include "timeval.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_lockfile
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(lockfile)
+
 struct lockfile {
     struct hmap_node hmap_node;
     char *name;
index 5d64f54..c8582f3 100644 (file)
 #include "tag.h"
 #include "timeval.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_mac_learning
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(mac_learning)
+
 /* Returns the number of seconds since 'e' was last learned. */
 int
 mac_entry_age(const struct mac_entry *e)
index 25e0a64..aecc77e 100644 (file)
 #include "openvswitch/gre.h"
 #include "packets.h"
 #include "socket-util.h"
-
-#define THIS_MODULE VLM_netdev_gre
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(netdev_gre)
+
 struct netdev_dev_gre {
     struct netdev_dev netdev_dev;
 };
index 09a4612..a20a1c4 100644 (file)
@@ -61,9 +61,9 @@
 #include "socket-util.h"
 #include "shash.h"
 #include "svec.h"
-
-#define THIS_MODULE VLM_netdev_linux
 #include "vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(netdev_linux)
 \f
 /* These were introduced in Linux 2.6.14, so they might be missing if we have
  * old headers. */
index 1340eb7..7e8b199 100644 (file)
 #include "openvswitch/datapath-protocol.h"
 #include "packets.h"
 #include "socket-util.h"
-
-#define THIS_MODULE VLM_netdev_patch
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(netdev_patch)
+
 struct netdev_dev_patch {
     struct netdev_dev netdev_dev;
 };
index 58858f9..9683411 100644 (file)
 #include "openvswitch/datapath-protocol.h"
 #include "shash.h"
 #include "socket-util.h"
-
-#define THIS_MODULE VLM_netdev_vport
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(netdev_vport)
+
 struct netdev_vport_notifier {
     struct netdev_notifier notifier;
     struct list list_node;
index 38f4dd5..7d834ad 100644 (file)
 #include "poll-loop.h"
 #include "shash.h"
 #include "svec.h"
-
-#define THIS_MODULE VLM_netdev
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(netdev)
+
 static const struct netdev_class *base_netdev_classes[] = {
 #ifdef HAVE_NETLINK
     &netdev_linux_class,
index d59f65e..2f7bc0a 100644 (file)
@@ -31,9 +31,9 @@
 #include "poll-loop.h"
 #include "timeval.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_netlink
+
+VLOG_DEFINE_THIS_MODULE(netlink)
 
 /* Linux header file confusion causes this to be undefined. */
 #ifndef SOL_NETLINK
index cedeb67..fd54a03 100644 (file)
 #include "ofpbuf.h"
 #include "packets.h"
 #include "random.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#define THIS_MODULE VLM_ofp_util
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(ofp_util)
 
 /* Rate limit for OpenFlow message parse errors.  These always indicate a bug
  * in the peer and so there's not much point in showing a lot of them. */
index c57175a..5eb4ec7 100644 (file)
@@ -25,8 +25,7 @@
 #include "util.h"
 #include "vlog.h"
 
-#define THIS_MODULE VLM_ovsdb_error
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(ovsdb_error)
 
 struct ovsdb_error {
     const char *tag;            /* String for "error" member. */
index f32fe0e..2a43781 100644 (file)
 #include "poll-loop.h"
 #include "shash.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_ovsdb_idl
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(ovsdb_idl)
+
 /* An arc from one idl_row to another.  When row A contains a UUID that
  * references row B, this is represented by an arc from A (the source) to B
  * (the destination).
index 028dd0c..cc15411 100644 (file)
 #include <string.h>
 #include "compiler.h"
 #include "ofpbuf.h"
-
-#define THIS_MODULE VLM_pcap
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(pcap)
+
 struct pcap_hdr {
     uint32_t magic_number;   /* magic number */
     uint16_t version_major;  /* major version number */
index 91034b0..70360b9 100644 (file)
 #include "fatal-signal.h"
 #include "list.h"
 #include "timeval.h"
-
-#define THIS_MODULE VLM_poll_loop
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(poll_loop)
+
 /* An event that will wake the following call to poll_block(). */
 struct poll_waiter {
     /* Set when the waiter is created. */
index af867ef..a201a88 100644 (file)
 #include "poll-loop.h"
 #include "socket-util.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_process
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(process)
+
 struct process {
     struct list node;
     char *name;
index 36828f3..d254356 100644 (file)
 #include "timeval.h"
 #include "util.h"
 #include "vconn.h"
-
-#define THIS_MODULE VLM_rconn
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(rconn)
+
 #define STATES                                  \
     STATE(VOID, 1 << 0)                         \
     STATE(BACKOFF, 1 << 1)                      \
index 372c2eb..169f317 100644 (file)
 #include <stdlib.h>
 
 #include "poll-loop.h"
-
-#define THIS_MODULE VLM_reconnect
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(reconnect)
+
 #define STATES                                  \
     STATE(VOID, 1 << 0)                         \
     STATE(BACKOFF, 1 << 1)                      \
index 1d302ea..f5a6df8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "coverage.h"
 #include "netlink.h"
 #include "ofpbuf.h"
-
-#define THIS_MODULE VLM_rtnetlink
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(rtnetlink)
+
 /* rtnetlink socket. */
 static struct nl_sock *notify_sock;
 
index bf563ed..16a321c 100644 (file)
@@ -32,9 +32,9 @@
 #include <unistd.h>
 #include "fatal-signal.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_socket_util
+
+VLOG_DEFINE_THIS_MODULE(socket_util)
 
 /* Sets 'fd' to non-blocking mode.  Returns 0 if successful, otherwise a
  * positive errno value. */
index 38885c0..c5c8b3b 100644 (file)
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -17,6 +17,8 @@
 /* Based on sample implementation in 802.1D-1998.  Above copyright and license
  * applies to all modifications. */
 
+#include <config.h>
+
 #include "stp.h"
 #include <sys/types.h>
 #include <netinet/in.h>
 #include "ofpbuf.h"
 #include "packets.h"
 #include "util.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#include "vlog.h"
-#define THIS_MODULE VLM_stp
+VLOG_DEFINE_THIS_MODULE(stp)
 
 /* Ethernet address used as the destination for STP frames. */
 const uint8_t stp_eth_addr[ETH_ADDR_LEN]
index cc897b3..9410009 100644 (file)
@@ -31,9 +31,9 @@
 #include "util.h"
 #include "stream-provider.h"
 #include "stream.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_stream_fd
+
+VLOG_DEFINE_THIS_MODULE(stream_fd)
 
 /* Active file descriptor stream. */
 
index 1944cb9..851e7a7 100644 (file)
@@ -41,9 +41,9 @@
 #include "stream-provider.h"
 #include "stream.h"
 #include "timeval.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_stream_ssl
+
+VLOG_DEFINE_THIS_MODULE(stream_ssl)
 
 /* Active SSL. */
 
index 2f7e798..d004777 100644 (file)
@@ -30,9 +30,9 @@
 #include "util.h"
 #include "stream-provider.h"
 #include "stream-fd.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_stream_tcp
+
+VLOG_DEFINE_THIS_MODULE(stream_tcp)
 
 /* Active TCP. */
 
index 930f548..20aa5b4 100644 (file)
@@ -33,9 +33,9 @@
 #include "util.h"
 #include "stream-provider.h"
 #include "stream-fd.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_stream_unix
+
+VLOG_DEFINE_THIS_MODULE(stream_unix)
 
 /* Active UNIX socket. */
 
index acbefc2..4d894e7 100644 (file)
 #include "poll-loop.h"
 #include "random.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_stream
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(stream)
+
 /* State of an active stream.*/
 enum stream_state {
     SCS_CONNECTING,             /* Underlying stream is not connected. */
index bc3df23..79c8355 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <string.h>
 #include "dynamic-string.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_svec
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(svec)
+
 void
 svec_init(struct svec *svec)
 {
index e83f573..b95d1f4 100644 (file)
@@ -27,9 +27,9 @@
 #include "coverage.h"
 #include "fatal-signal.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_timeval
+
+VLOG_DEFINE_THIS_MODULE(timeval)
 
 /* The clock to use for measuring time intervals.  This is CLOCK_MONOTONIC by
  * preference, but on systems that don't have a monotonic clock we fall back
index 7078568..ac756a8 100644 (file)
 #include "socket-util.h"
 #include "svec.h"
 #include "util.h"
+#include "vlog.h"
 
 #ifndef SCM_CREDENTIALS
 #include <time.h>
 #endif
 
-#define THIS_MODULE VLM_unixctl
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(unixctl)
 \f
 struct unixctl_command {
     unixctl_cb_func *cb;
index 19f13dd..9fc99f0 100644 (file)
 #include <string.h>
 #include <unistd.h>
 #include "coverage.h"
-
-#define THIS_MODULE VLM_util
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(util)
+
 const char *program_name;
 
 void
index df728d5..e6c2946 100644 (file)
@@ -32,9 +32,9 @@
 #include "util.h"
 #include "vconn-provider.h"
 #include "vconn.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_vconn_stream
+
+VLOG_DEFINE_THIS_MODULE(vconn_stream)
 
 /* Active stream socket vconn. */
 
index b558f80..99b6e7b 100644 (file)
 #include "poll-loop.h"
 #include "random.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_vconn
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(vconn)
+
 /* State of an active vconn.*/
 enum vconn_state {
     /* This is the ordinary progression of states. */
index a77a6e5..3887129 100644 (file)
@@ -33,7 +33,7 @@
 #include "unixctl.h"
 #include "util.h"
 
-#define THIS_MODULE VLM_vlog
+VLOG_DEFINE_THIS_MODULE(vlog)
 
 /* Name for each logging level. */
 static const char *level_names[VLL_N_LEVELS] = {
index f50b76a..53e8f39 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -129,10 +129,12 @@ void vlog_rate_limit(enum vlog_module, enum vlog_level,
                      struct vlog_rate_limit *, const char *, ...)
     __attribute__((format(printf, 4, 5)));
 
-/* Convenience macros.  To use these, define THIS_MODULE as a macro that
- * expands to the module used by the current source file, e.g.
- *      #include "vlog.h"
- *      #define THIS_MODULE VLM_netlink
+/* Defines THIS_MODULE as MODULE, for use with the convenience macros below. */
+#define VLOG_DEFINE_THIS_MODULE(MODULE) enum { THIS_MODULE = VLM_##MODULE };
+
+/* Convenience macros.  These assume that THIS_MODULE is defined as the current
+ * module, as set up by e.g. the VLOG_DEFINE_MODULE macro above.
+ *
  * Guaranteed to preserve errno.
  */
 #define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__)
index 0b84c3e..69eed5d 100644 (file)
 #include "socket-util.h"
 #include "svec.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_collectors
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(collectors)
+
 struct collectors {
     int *fds;                     /* Sockets. */
     size_t n_fds;                 /* Number of sockets. */
index 84f092e..008ad62 100644 (file)
 #include "packets.h"
 #include "status.h"
 #include "stream-ssl.h"
-
-#define THIS_MODULE VLM_discovery
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(discovery)
+
 struct discovery {
     char *dpif_name;
     char *re;
index a86ee39..04be5ce 100644 (file)
 #include "status.h"
 #include "timeval.h"
 #include "vconn.h"
-
-#define THIS_MODULE VLM_fail_open
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(fail_open)
+
 /*
  * Fail-open mode.
  *
index 884cf1d..44bcd72 100644 (file)
 #include "poll-loop.h"
 #include "status.h"
 #include "timeval.h"
-
-#define THIS_MODULE VLM_in_band
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(in_band)
+
 /* In-band control allows a single network to be used for OpenFlow
  * traffic and other data traffic.  Refer to ovs-vswitchd.conf(5) and 
  * secchan(8) for a description of configuring in-band control.
index 67932f0..dd14a8b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "svec.h"
 #include "timeval.h"
 #include "util.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#define THIS_MODULE VLM_netflow
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(netflow)
 
 #define NETFLOW_V5_VERSION 5
 
index cc6a693..c74c736 100644 (file)
 #include "sflow_api.h"
 #include "socket-util.h"
 #include "timeval.h"
-
-#define THIS_MODULE VLM_sflow
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(sflow)
+
 struct ofproto_sflow_port {
     struct netdev *netdev;      /* Underlying network device, for stats. */
     SFLDataSource_instance dsi; /* sFlow library's notion of port number. */
index cf49139..66b957e 100644 (file)
 #include "timeval.h"
 #include "unixctl.h"
 #include "vconn.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#define THIS_MODULE VLM_ofproto
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(ofproto)
 
 #include "sflow_api.h"
 
index b04eb59..49e5c4d 100644 (file)
 #include "timeval.h"
 #include "util.h"
 #include "vconn.h"
-
-#define THIS_MODULE VLM_pktbuf
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(pktbuf)
+
 /* Buffers are identified by a 32-bit opaque ID.  We divide the ID
  * into a buffer number (low bits) and a cookie (high bits).  The buffer number
  * is an index into an array of buffers.  The cookie distinguishes between
index 27dc86c..a8f522d 100644 (file)
 #include "svec.h"
 #include "timeval.h"
 #include "vconn.h"
-
-#define THIS_MODULE VLM_status
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(status)
+
 struct status_category {
     struct list node;
     char *name;
index f0913e9..846f556 100644 (file)
 #include "transaction.h"
 #include "uuid.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_ovsdb_file
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(ovsdb_file)
+
 /* Minimum number of milliseconds between database compactions. */
 #define COMPACT_MIN_MSEC        (10 * 60 * 1000) /* 10 minutes. */
 
index bc717e4..71a4489 100644 (file)
 #include "timeval.h"
 #include "transaction.h"
 #include "trigger.h"
-
-#define THIS_MODULE VLM_ovsdb_jsonrpc_server
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(ovsdb_jsonrpc_server)
+
 struct ovsdb_jsonrpc_remote;
 struct ovsdb_jsonrpc_session;
 
index 09b9f1f..b532f7c 100644 (file)
 #include "socket-util.h"
 #include "transaction.h"
 #include "util.h"
-
-#define THIS_MODULE VLM_ovsdb_log
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(ovsdb_log)
+
 enum ovsdb_log_mode {
     OVSDB_LOG_READ,
     OVSDB_LOG_WRITE
index 8a48e8b..b8a2fa4 100644 (file)
@@ -41,9 +41,9 @@
 #include "table.h"
 #include "timeval.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_ovsdb_client
+
+VLOG_DEFINE_THIS_MODULE(ovsdb_client)
 
 /* --format: Output formatting. */
 static enum {
index ecc620d..4ca9c2d 100644 (file)
@@ -45,9 +45,9 @@
 #include "trigger.h"
 #include "util.h"
 #include "unixctl.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_ovsdb_server
+
+VLOG_DEFINE_THIS_MODULE(ovsdb_server)
 
 #if HAVE_OPENSSL
 /* SSL configuration. */
index b485e8b..0da2085 100644 (file)
@@ -34,9 +34,9 @@
 #include "table.h"
 #include "timeval.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_ovsdb_tool
+
+VLOG_DEFINE_THIS_MODULE(ovsdb_tool)
 
 /* -m, --more: Verbosity level for "show-log" command output. */
 static int show_log_verbosity;
index f190edc..92b84ae 100644 (file)
@@ -36,9 +36,9 @@
 #include "unixctl.h"
 #include "util.h"
 #include "vconn.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_controller
+
+VLOG_DEFINE_THIS_MODULE(controller)
 
 #define MAX_SWITCHES 16
 #define MAX_LISTENERS 16
index f5da642..7cd1edf 100644 (file)
@@ -33,9 +33,9 @@
 #include "timeval.h"
 #include "unixctl.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_ovs_discover
+
+VLOG_DEFINE_THIS_MODULE(ovs_discover)
 
 struct iface {
     const char *name;
index 077ae74..fe44f27 100644 (file)
@@ -40,9 +40,9 @@
 #include "svec.h"
 #include "timeval.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_dpctl
+
+VLOG_DEFINE_THIS_MODULE(dpctl)
 
 static const struct command all_commands[];
 
index 31b58a6..54183e5 100644 (file)
 #include "timeval.h"
 #include "util.h"
 #include "vconn.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#include "vlog.h"
-#define THIS_MODULE VLM_ofctl
+VLOG_DEFINE_THIS_MODULE(ofctl)
 
 #define DEFAULT_IDLE_TIMEOUT 60
 
index 1aa3ef5..bb77d58 100644 (file)
@@ -44,9 +44,9 @@
 #include "unixctl.h"
 #include "util.h"
 #include "vconn.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_openflowd
+
+VLOG_DEFINE_THIS_MODULE(openflowd)
 
 /* Settings that may be configured by the user. */
 struct ofsettings {
index 17ebdb4..c18de47 100644 (file)
@@ -41,9 +41,9 @@
 #include "vswitchd/vswitch-idl.h"
 #include "timeval.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_vsctl
+
+VLOG_DEFINE_THIS_MODULE(vsctl)
 
 /* vsctl_fatal() also logs the error, so it is preferred in this file. */
 #define ovs_fatal please_use_vsctl_fatal_instead_of_ovs_fatal
index e4d9cb7..be0e875 100644 (file)
 #include "vconn.h"
 #include "vswitchd/vswitch-idl.h"
 #include "xenserver.h"
+#include "vlog.h"
 #include "xtoxll.h"
 #include "sflow_api.h"
 
-#define THIS_MODULE VLM_bridge
-#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(bridge)
 
 struct dst {
     uint16_t vlan;
index 6e620e1..5e59373 100644 (file)
 #include "timeval.h"
 #include "unixctl.h"
 #include "util.h"
+#include "vlog.h"
 #include "vswitchd/vswitch-idl.h"
 
-#include "vlog.h"
-#define THIS_MODULE VLM_brcompatd
+VLOG_DEFINE_THIS_MODULE(brcompatd)
 
 
 /* xxx Just hangs if datapath is rmmod/insmod.  Learn to reconnect? */
index a027b8c..541cdcb 100644 (file)
 #include "unixctl.h"
 #include "util.h"
 #include "vconn.h"
+#include "vlog.h"
 #include "vswitchd/vswitch-idl.h"
 
-#include "vlog.h"
-#define THIS_MODULE VLM_vswitchd
+VLOG_DEFINE_THIS_MODULE(vswitchd)
 
 static unixctl_cb_func ovs_vswitchd_exit;
 
index 106a7c3..6a8f875 100644 (file)
 #include "hmap.h"
 #include "shash.h"
 #include "svec.h"
-
-#define THIS_MODULE VLM_proc_net_compat
 #include "vlog.h"
 
+VLOG_DEFINE_THIS_MODULE(proc_net_compat)
+
 /* Netlink socket to bridge compatibility kernel module. */
 static struct nl_sock *brc_sock;
 
index 03c4955..976d716 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009 Nicira Networks
+/* Copyright (c) 2009, 2010 Nicira Networks
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
 #include <unistd.h>
 #include "dynamic-string.h"
 #include "process.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_xenserver
+
+VLOG_DEFINE_THIS_MODULE(xenserver)
 
 static char *
 read_host_uuid(void)