2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

vlog: Add a new log level "off".

Until now, "emer" has effectively been "off" because no messages were ever
logged at "emer" level.  Justin points out that it is useful to use "emer"
for messages that indicate a fatal error.  This commit makes that change
and adds a new "off" level to really turn off all logging to a facility.
This commit is contained in:
Ben Pfaff
2011-07-28 10:19:42 -07:00
committed by Justin Pettit
parent 733a287e17
commit c1a543a8d6
17 changed files with 58 additions and 52 deletions

View File

@@ -1,5 +1,11 @@
post v1.1.0
------------------------
- A new log level "off" has been added. Configuring a log facility
"off" prevents any messages from being logged to it. Previously,
"emer" was effectively "off" because no messages were ever logged at
level "emer". Now, errors that cause a process to exit are logged
at "emer" level.
- The new "-s" option for "ovs-dpctl show" prints packet and byte
counters for each port.
- ovs-ofctl:

View File

@@ -410,7 +410,7 @@ close_standard_fds(void)
}
/* Disable logging to stderr to avoid wasting CPU time. */
vlog_set_levels(NULL, VLF_CONSOLE, VLL_EMER);
vlog_set_levels(NULL, VLF_CONSOLE, VLL_OFF);
}
/* If daemonization is configured, then starts daemonization, by forking and

View File

@@ -19,7 +19,7 @@ facilities. If it is omitted, \fIfacility\fR defaults to \fBANY\fR.
The log level for the \fBfile\fR facility has no effect unless
\fB\*(PN\fR was invoked with the \fB\-\-log\-file\fR option.
.IP \(bu
\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR,
\fIlevel\fR must be one of \fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR,
\fBinfo\fR, or
\fBdbg\fR, designating the minimum severity of a message for it to be
logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR.

View File

@@ -186,7 +186,7 @@ update_min_level(struct vlog_module *module)
{
enum vlog_facility facility;
module->min_level = VLL_EMER;
module->min_level = VLL_OFF;
for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
if (log_file || facility != VLF_FILE) {
enum vlog_level level = module->levels[facility];
@@ -692,27 +692,26 @@ vlog(const struct vlog_module *module, enum vlog_level level,
}
void
vlog_fatal_valist(const struct vlog_module *module_, enum vlog_level level,
vlog_fatal_valist(const struct vlog_module *module_,
const char *message, va_list args)
{
struct vlog_module *module = (struct vlog_module *) module_;
/* Don't log this message to the console to avoid redundancy with the
* message written by the later ovs_fatal_valist(). */
module->levels[VLF_CONSOLE] = VLL_EMER;
module->levels[VLF_CONSOLE] = VLL_OFF;
vlog_valist(module, level, message, args);
vlog_valist(module, VLL_EMER, message, args);
ovs_fatal_valist(0, message, args);
}
void
vlog_fatal(const struct vlog_module *module, enum vlog_level level,
const char *message, ...)
vlog_fatal(const struct vlog_module *module, const char *message, ...)
{
va_list args;
va_start(args, message);
vlog_fatal_valist(module, level, message, args);
vlog_fatal_valist(module, message, args);
va_end(args);
}

View File

@@ -28,12 +28,13 @@
extern "C" {
#endif
/* Logging importance levels.
/* Logging severity levels.
*
* The following log levels, in descending order of importance, are enabled by
* A logging severity level of OFF suppresses logging. Messages at the
* following log levels, in descending order of importance, are enabled by
* default:
*
* - EMER: Not currently used.
* - EMER: The process is aborting due to unrecoverable failure.
*
* - ERR: A high-level operation or a subsystem failed. Attention is
* warranted.
@@ -50,6 +51,7 @@ extern "C" {
* system, or that would commonly cause too-voluminous log output.
*/
#define VLOG_LEVELS \
VLOG_LEVEL(OFF, LOG_ALERT) \
VLOG_LEVEL(EMER, LOG_ALERT) \
VLOG_LEVEL(ERR, LOG_ERR) \
VLOG_LEVEL(WARN, LOG_WARNING) \
@@ -163,12 +165,10 @@ void vlog_valist(const struct vlog_module *, enum vlog_level,
const char *, va_list)
PRINTF_FORMAT (3, 0);
void vlog_fatal(const struct vlog_module *, enum vlog_level,
const char *format, ...)
PRINTF_FORMAT (3, 4) NO_RETURN;
void vlog_fatal_valist(const struct vlog_module *, enum vlog_level,
const char *, va_list)
PRINTF_FORMAT (3, 0) NO_RETURN;
void vlog_fatal(const struct vlog_module *, const char *format, ...)
PRINTF_FORMAT (2, 3) NO_RETURN;
void vlog_fatal_valist(const struct vlog_module *, const char *format, va_list)
PRINTF_FORMAT (2, 0) NO_RETURN;
void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
struct vlog_rate_limit *, const char *, ...)
@@ -187,7 +187,7 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
*
* Guaranteed to preserve errno.
*/
#define VLOG_FATAL(...) vlog_fatal(THIS_MODULE, VLL_ERR, __VA_ARGS__)
#define VLOG_FATAL(...) vlog_fatal(THIS_MODULE, __VA_ARGS__)
#define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__)
#define VLOG_ERR(...) VLOG(VLL_ERR, __VA_ARGS__)
#define VLOG_WARN(...) VLOG(VLL_WARN, __VA_ARGS__)
@@ -197,7 +197,6 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
/* More convenience macros, for testing whether a given level is enabled in
* THIS_MODULE. When constructing a log message is expensive, this enables it
* to be skipped. */
#define VLOG_IS_EMER_ENABLED() true
#define VLOG_IS_ERR_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_ERR)
#define VLOG_IS_WARN_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_WARN)
#define VLOG_IS_INFO_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_INFO)

View File

@@ -21,7 +21,7 @@ will not take place unless \fB\-\-log\-file\fR is also specified (see
below).
.
.IP \(bu
\fIlevel\fR must be one of \fBemer\fR, \fBerr\fR, \fBwarn\fR,
\fIlevel\fR must be one of \fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR,
\fBinfo\fR, or
\fBdbg\fR, designating the minimum severity of a message for it to be
logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR.

View File

@@ -703,7 +703,7 @@ configure_datapath: bridge - xenbr2
configure_datapath: physical - [u'eth2']
configure_datapath: extra ports - []
configure_datapath: extra bonds - []
/usr/bin/ovs-vsctl --timeout=5 -vANY:console:emer get-fail-mode xenbr2
/usr/bin/ovs-vsctl --timeout=5 -vANY:console:off get-fail-mode xenbr2
Applying changes to /etc/sysconfig/network-scripts/route-xenbr2 configuration
Applying changes to /etc/sysconfig/network configuration
Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration
@@ -718,7 +718,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration
set Bridge xenbr2 fail_mode=secure
remove Bridge xenbr2 other_config disable-in-band
br-set-external-id xenbr2 xs-network-uuids d08c8749-0c8f-9e8d-ce25-fd364661ee99
/usr/bin/ovs-vsctl --timeout=5 -vANY:console:emer get interface eth2 ofport
/usr/bin/ovs-vsctl --timeout=5 -vANY:console:off get interface eth2 ofport
/usr/bin/ovs-ofctl add-flow xenbr2 idle_timeout=0,priority=0,in_port=5,arp,nw_proto=1,actions=local
/usr/bin/ovs-ofctl add-flow xenbr2 idle_timeout=0,priority=0,in_port=local,arp,dl_src=00:15:17:a0:29:80,actions=5
/usr/bin/ovs-ofctl add-flow xenbr2 idle_timeout=0,priority=0,in_port=5,dl_dst=00:15:17:a0:29:80,actions=local

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2010 Nicira Networks.
* Copyright (c) 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ main(void)
int old_time;
char line[128];
vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_EMER);
vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_OFF);
now = 1000;
reconnect = reconnect_create(now);

View File

@@ -70,7 +70,8 @@ set the logging levels for all modules. The \fIfacility\fR may be
system log or to the console, respectively, or \fBANY\fR to set the
logging levels for both facilities. If it is omitted,
\fIfacility\fR defaults to \fBANY\fR. The \fIlevel\fR must be one of
\fBemer\fR, \fBerr\fR, \fBwarn\fR, \fBinfo\fR, or \fBdbg\fR, designating the
\fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR, \fBinfo\fR, or
\fBdbg\fR, designating the
minimum severity of a message for it to be logged. If it is omitted,
\fIlevel\fR defaults to \fBdbg\fR.
.

View File

@@ -81,22 +81,23 @@ main(int argc, char *argv[])
static void
usage(void)
{
printf("%s, for querying and controlling Open vSwitch daemon\n"
"usage: %s [TARGET] COMMAND [ARG...]\n"
"Targets:\n"
" -t, --target=TARGET pidfile or socket to contact\n"
"Common commands:\n"
" help List commands supported by the target\n"
" vlog/list List current logging levels\n"
" vlog/set MODULE[:FACILITY[:LEVEL]]\n"
" Set MODULE and FACILITY log level to LEVEL\n"
" MODULE may be any valid module name or 'ANY'\n"
" FACILITY may be 'syslog', 'console', 'file', or 'ANY' (default)\n"
" LEVEL may be 'emer', 'err', 'warn', 'info', or 'dbg' (default)\n"
" vlog/reopen Make the program reopen its log file\n"
"Other options:\n"
" -h, --help Print this helpful information\n"
" -V, --version Display version information\n",
printf("\
%s, for querying and controlling Open vSwitch daemon\n\
usage: %s [TARGET] COMMAND [ARG...]\n\
Targets:\n\
-t, --target=TARGET pidfile or socket to contact\n\
Common commands:\n\
help List commands supported by the target\n\
vlog/list List current logging levels\n\
vlog/set MODULE[:FACILITY[:LEVEL]]\n\
Set MODULE and FACILITY log level to LEVEL\n\
MODULE may be any valid module name or 'ANY'\n\
FACILITY may be 'syslog', 'console', 'file', or 'ANY' (default)\n\
LEVEL may be 'off', 'emer', 'err', 'warn', 'info', or 'dbg' (default)\n\
vlog/reopen Make the program reopen its log file\n\
Other options:\n\
-h, --help Print this helpful information\n\
-V, --version Display version information\n",
program_name, program_name);
exit(EXIT_SUCCESS);
}

View File

@@ -61,7 +61,7 @@ ovs_vsctl () {
}
ovsdb_tool () {
ovsdb-tool -vANY:console:emer "$@"
ovsdb-tool -vANY:console:off "$@"
}
create_db () {

View File

@@ -444,7 +444,7 @@ vsctl_fatal(const char *format, ...)
message = xvasprintf(format, args);
va_end(args);
vlog_set_levels(&VLM_vsctl, VLF_CONSOLE, VLL_EMER);
vlog_set_levels(&VLM_vsctl, VLF_CONSOLE, VLL_OFF);
VLOG_ERR("%s", message);
ovs_error(0, "%s", message);
vsctl_exit(EXIT_FAILURE);

View File

@@ -215,7 +215,7 @@ def setControllerCfg(controller):
"--", "set-manager", 'ssl:' + controller + ':6632'])
def vswitchCfgQuery(action_args):
cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args
cmd = [vsctl, "--timeout=5", "-vANY:console:off"] + action_args
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
if len(output) == 0 or output[0] == None:
output = ""
@@ -224,7 +224,7 @@ def vswitchCfgQuery(action_args):
return output
def vswitchCfgMod(action_args):
cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args
cmd = [vsctl, "--timeout=5", "-vANY:console:off"] + action_args
exitcode = subprocess.call(cmd)
if exitcode != 0:
raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE",

View File

@@ -145,11 +145,11 @@ if test ! -e /etc/openvswitch/conf.db; then
install -d -m 755 -o root -g root /etc/openvswitch
# Create ovs-vswitchd config database
ovsdb-tool -vANY:console:emer create /etc/openvswitch/conf.db \
ovsdb-tool -vANY:console:off create /etc/openvswitch/conf.db \
/usr/share/openvswitch/vswitch.ovsschema
# Create initial table in config database
ovsdb-tool -vANY:console:emer transact /etc/openvswitch/conf.db \
ovsdb-tool -vANY:console:off transact /etc/openvswitch/conf.db \
'[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
> /dev/null
fi

View File

@@ -721,7 +721,7 @@ class DatapathVswitch(Datapath):
def vswitchCfgQuery(action_args):
cmd = ['%s/usr/bin/ovs-vsctl' % root_prefix(),
'--timeout=5', '-vANY:console:emer'] + action_args
'--timeout=5', '-vANY:console:off'] + action_args
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
if len(output) == 0 or output[0] == None:
output = ""

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2007-2010 Citrix Systems Inc.
# Copyright (c) 2007-2011 Citrix Systems Inc.
# Copyright (c) 2009,2010,2011 Nicira Networks.
#
# This program is free software; you can redistribute it and/or modify
@@ -86,7 +86,7 @@ class VSwitchConfig:
@staticmethod
def Get(action):
try:
arg = [vsctl, "--timeout=30", "-vANY:console:emer"] + action.split()
arg = [vsctl, "--timeout=30", "-vANY:console:off"] + action.split()
output = ShellPipe(arg).Stdout()
except StandardError, e:
XSLogError("config retrieval error: " + str(e))

View File

@@ -118,7 +118,7 @@ def get_iface_id(if_name, xs_vif_uuid):
return xs_vif_uuid
def call_vsctl(args):
cmd = [vsctl, "--timeout=30", "-vANY:console:emer"] + args
cmd = [vsctl, "--timeout=30", "-vANY:console:off"] + args
exitcode = subprocess.call(cmd)
if exitcode != 0:
s_log.warning("Couldn't call ovs-vsctl")