In OVS, we currently use the term 'facility' to mean the place
where we log (syslog, console or file). In Linux's syslog() and
rfc5424, the term 'facility' is used to specify what type of program
is logging the message (e.g: LOG_DAEMON). This causes confusion
while reading vlog's code. This commit changes the term 'facility'
to 'destination'.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
17 files changed:
This is generic tunneling mechanism for userspace datapath.
- Support for multicast snooping (IGMPv1 and IGMPv2)
- Support for Linux kernels up to 3.18.x
This is generic tunneling mechanism for userspace datapath.
- Support for multicast snooping (IGMPv1 and IGMPv2)
- Support for Linux kernels up to 3.18.x
+ - The documentation now use the term 'destination' to mean one of syslog,
+ console or file for vlog logging instead of the previously used term
+ 'facility'.
const char *vlog_get_level_name(enum vlog_level);
enum vlog_level vlog_get_level_val(const char *name);
const char *vlog_get_level_name(enum vlog_level);
enum vlog_level vlog_get_level_val(const char *name);
-/* Facilities that we can log to. */
-#define VLOG_FACILITIES \
- VLOG_FACILITY(SYSLOG, "ovs|%05N|%c%T|%p|%m") \
- VLOG_FACILITY(CONSOLE, "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m") \
- VLOG_FACILITY(FILE, "%D{%Y-%m-%dT%H:%M:%S.###Z}|%05N|%c%T|%p|%m")
-enum vlog_facility {
-#define VLOG_FACILITY(NAME, PATTERN) VLF_##NAME,
- VLOG_FACILITIES
-#undef VLOG_FACILITY
- VLF_N_FACILITIES,
- VLF_ANY_FACILITY = -1
+/* Destinations that we can log to. */
+#define VLOG_DESTINATIONS \
+ VLOG_DESTINATION(SYSLOG, "ovs|%05N|%c%T|%p|%m") \
+ VLOG_DESTINATION(CONSOLE, "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m") \
+ VLOG_DESTINATION(FILE, "%D{%Y-%m-%dT%H:%M:%S.###Z}|%05N|%c%T|%p|%m")
+enum vlog_destination {
+#define VLOG_DESTINATION(NAME, PATTERN) VLF_##NAME,
+ VLOG_DESTINATIONS
+#undef VLOG_DESTINATION
+ VLF_N_DESTINATIONS,
+ VLF_ANY_DESTINATION = -1
-const char *vlog_get_facility_name(enum vlog_facility);
-enum vlog_facility vlog_get_facility_val(const char *name);
+const char *vlog_get_destination_name(enum vlog_destination);
+enum vlog_destination vlog_get_destination_val(const char *name);
/* A log module. */
struct vlog_module {
struct ovs_list list;
const char *name; /* User-visible name. */
/* A log module. */
struct vlog_module {
struct ovs_list list;
const char *name; /* User-visible name. */
- int levels[VLF_N_FACILITIES]; /* Minimum log level for each facility. */
- int min_level; /* Minimum log level for any facility. */
+ int levels[VLF_N_DESTINATIONS]; /* Minimum log level for each
+ destination. */
+ int min_level; /* Minimum log level for any destination. */
bool honor_rate_limits; /* Set false to ignore rate limits. */
};
bool honor_rate_limits; /* Set false to ignore rate limits. */
};
}
/* Configuring how each module logs messages. */
}
/* Configuring how each module logs messages. */
-enum vlog_level vlog_get_level(const struct vlog_module *, enum vlog_facility);
+enum vlog_level vlog_get_level(const struct vlog_module *,
+ enum vlog_destination);
void vlog_set_levels(struct vlog_module *,
void vlog_set_levels(struct vlog_module *,
- enum vlog_facility, enum vlog_level);
+ enum vlog_destination, enum vlog_level);
char *vlog_set_levels_from_string(const char *) OVS_WARN_UNUSED_RESULT;
void vlog_set_levels_from_string_assert(const char *);
char *vlog_get_levels(void);
char *vlog_set_levels_from_string(const char *) OVS_WARN_UNUSED_RESULT;
void vlog_set_levels_from_string_assert(const char *);
char *vlog_get_levels(void);
struct vlog_rate_limit *);
void vlog_set_verbosity(const char *arg);
struct vlog_rate_limit *);
void vlog_set_verbosity(const char *arg);
-/* Configuring log facilities. */
-void vlog_set_pattern(enum vlog_facility, const char *pattern);
+/* Configuring log destinations. */
+void vlog_set_pattern(enum vlog_destination, const char *pattern);
int vlog_set_log_file(const char *file_name);
int vlog_reopen_log_file(void);
int vlog_set_log_file(const char *file_name);
int vlog_reopen_log_file(void);
-[\fB\-v\fR[\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]]]\&...
+[\fB\-v\fR[\fImodule\fR[\fB:\fIdestination\fR[\fB:\fIlevel\fR]]]]\&...
-[\fB\-\-verbose[=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]]]\&...
+[\fB\-\-verbose[=\fImodule\fR[\fB:\fIdestination\fR[\fB:\fIlevel\fR]]]]\&...
.br
[\fB\-\-log\-file\fR[\fB=\fIfile\fR]]
.br
[\fB\-\-log\-file\fR[\fB=\fIfile\fR]]
These commands manage \fB\*(PN\fR's logging settings.
.IP "\fBvlog/set\fR [\fIspec\fR]"
Sets logging levels. Without any \fIspec\fR, sets the log level for
These commands manage \fB\*(PN\fR's logging settings.
.IP "\fBvlog/set\fR [\fIspec\fR]"
Sets logging levels. Without any \fIspec\fR, sets the log level for
-every module and facility to \fBdbg\fR. Otherwise, \fIspec\fR is a
+every module and destination to \fBdbg\fR. Otherwise, \fIspec\fR is a
list of words separated by spaces or commas or colons, up to one from
each category below:
.
list of words separated by spaces or commas or colons, up to one from
each category below:
.
For compatibility with older versions of OVS, \fBany\fR is accepted as
a word but has no effect.
.RE
For compatibility with older versions of OVS, \fBany\fR is accepted as
a word but has no effect.
.RE
-.IP "\fBvlog/set PATTERN:\fIfacility\fB:\fIpattern\fR"
-Sets the log pattern for \fIfacility\fR to \fIpattern\fR. Refer to
+.IP "\fBvlog/set PATTERN:\fIdestination\fB:\fIpattern\fR"
+Sets the log pattern for \fIdestination\fR to \fIpattern\fR. Refer to
\fBovs\-appctl\fR(8) for a description of the valid syntax for \fIpattern\fR.
.
.IP "\fBvlog/list\fR"
\fBovs\-appctl\fR(8) for a description of the valid syntax for \fIpattern\fR.
.
.IP "\fBvlog/list\fR"
/* The log modules. */
struct ovs_list vlog_modules = OVS_LIST_INITIALIZER(&vlog_modules);
/* The log modules. */
struct ovs_list vlog_modules = OVS_LIST_INITIALIZER(&vlog_modules);
-/* Protects the 'pattern' in all "struct facility"s, so that a race between
+/* Protects the 'pattern' in all "struct destination"s, so that a race between
* changing and reading the pattern does not cause an access to freed
* memory. */
static struct ovs_rwlock pattern_rwlock = OVS_RWLOCK_INITIALIZER;
* changing and reading the pattern does not cause an access to freed
* memory. */
static struct ovs_rwlock pattern_rwlock = OVS_RWLOCK_INITIALIZER;
-/* Information about each facility. */
-struct facility {
+/* Information about each destination. */
+struct destination {
const char *name; /* Name. */
char *pattern OVS_GUARDED_BY(pattern_rwlock); /* Current pattern. */
bool default_pattern; /* Whether current pattern is the default. */
};
const char *name; /* Name. */
char *pattern OVS_GUARDED_BY(pattern_rwlock); /* Current pattern. */
bool default_pattern; /* Whether current pattern is the default. */
};
-static struct facility facilities[VLF_N_FACILITIES] = {
-#define VLOG_FACILITY(NAME, PATTERN) {#NAME, PATTERN, true},
- VLOG_FACILITIES
-#undef VLOG_FACILITY
+static struct destination destinations[VLF_N_DESTINATIONS] = {
+#define VLOG_DESTINATION(NAME, PATTERN) {#NAME, PATTERN, true},
+ VLOG_DESTINATIONS
+#undef VLOG_DESTINATION
};
/* Sequence number for the message currently being composed. */
};
/* Sequence number for the message currently being composed. */
return search_name_array(name, level_names, ARRAY_SIZE(level_names));
}
return search_name_array(name, level_names, ARRAY_SIZE(level_names));
}
-/* Returns the name for logging facility 'facility'. */
+/* Returns the name for logging destination 'destination'. */
-vlog_get_facility_name(enum vlog_facility facility)
+vlog_get_destination_name(enum vlog_destination destination)
- assert(facility < VLF_N_FACILITIES);
- return facilities[facility].name;
+ assert(destination < VLF_N_DESTINATIONS);
+ return destinations[destination].name;
-/* Returns the logging facility named 'name', or VLF_N_FACILITIES if 'name' is
- * not the name of a logging facility. */
-enum vlog_facility
-vlog_get_facility_val(const char *name)
+/* Returns the logging destination named 'name', or VLF_N_DESTINATIONS if
+ * 'name' is not the name of a logging destination. */
+enum vlog_destination
+vlog_get_destination_val(const char *name)
- for (i = 0; i < VLF_N_FACILITIES; i++) {
- if (!strcasecmp(facilities[i].name, name)) {
+ for (i = 0; i < VLF_N_DESTINATIONS; i++) {
+ if (!strcasecmp(destinations[i].name, name)) {
-/* Returns the current logging level for the given 'module' and 'facility'. */
+/* Returns the current logging level for the given 'module' and
+ * 'destination'. */
-vlog_get_level(const struct vlog_module *module, enum vlog_facility facility)
+vlog_get_level(const struct vlog_module *module,
+ enum vlog_destination destination)
- assert(facility < VLF_N_FACILITIES);
- return module->levels[facility];
+ assert(destination < VLF_N_DESTINATIONS);
+ return module->levels[destination];
}
static void
update_min_level(struct vlog_module *module) OVS_REQUIRES(&log_file_mutex)
{
}
static void
update_min_level(struct vlog_module *module) OVS_REQUIRES(&log_file_mutex)
{
- enum vlog_facility facility;
+ enum vlog_destination destination;
module->min_level = VLL_OFF;
module->min_level = VLL_OFF;
- for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
- if (log_fd >= 0 || facility != VLF_FILE) {
- enum vlog_level level = module->levels[facility];
+ for (destination = 0; destination < VLF_N_DESTINATIONS; destination++) {
+ if (log_fd >= 0 || destination != VLF_FILE) {
+ enum vlog_level level = module->levels[destination];
if (level > module->min_level) {
module->min_level = level;
}
if (level > module->min_level) {
module->min_level = level;
}
-set_facility_level(enum vlog_facility facility, struct vlog_module *module,
- enum vlog_level level)
+set_destination_level(enum vlog_destination destination,
+ struct vlog_module *module, enum vlog_level level)
- assert(facility >= 0 && facility < VLF_N_FACILITIES);
+ assert(destination >= 0 && destination < VLF_N_DESTINATIONS);
assert(level < VLL_N_LEVELS);
ovs_mutex_lock(&log_file_mutex);
if (!module) {
struct vlog_module *mp;
LIST_FOR_EACH (mp, list, &vlog_modules) {
assert(level < VLL_N_LEVELS);
ovs_mutex_lock(&log_file_mutex);
if (!module) {
struct vlog_module *mp;
LIST_FOR_EACH (mp, list, &vlog_modules) {
- mp->levels[facility] = level;
+ mp->levels[destination] = level;
update_min_level(mp);
}
} else {
update_min_level(mp);
}
} else {
- module->levels[facility] = level;
+ module->levels[destination] = level;
update_min_level(module);
}
ovs_mutex_unlock(&log_file_mutex);
}
update_min_level(module);
}
ovs_mutex_unlock(&log_file_mutex);
}
-/* Sets the logging level for the given 'module' and 'facility' to 'level'. A
- * null 'module' or a 'facility' of VLF_ANY_FACILITY is treated as a wildcard
- * across all modules or facilities, respectively. */
+/* Sets the logging level for the given 'module' and 'destination' to 'level'.
+ * A null 'module' or a 'destination' of VLF_ANY_DESTINATION is treated as a
+ * wildcard across all modules or destinations, respectively. */
-vlog_set_levels(struct vlog_module *module, enum vlog_facility facility,
+vlog_set_levels(struct vlog_module *module, enum vlog_destination destination,
- assert(facility < VLF_N_FACILITIES || facility == VLF_ANY_FACILITY);
- if (facility == VLF_ANY_FACILITY) {
- for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
- set_facility_level(facility, module, level);
+ assert(destination < VLF_N_DESTINATIONS ||
+ destination == VLF_ANY_DESTINATION);
+ if (destination == VLF_ANY_DESTINATION) {
+ for (destination = 0; destination < VLF_N_DESTINATIONS;
+ destination++) {
+ set_destination_level(destination, module, level);
- set_facility_level(facility, module, level);
+ set_destination_level(destination, module, level);
-do_set_pattern(enum vlog_facility facility, const char *pattern)
+do_set_pattern(enum vlog_destination destination, const char *pattern)
- struct facility *f = &facilities[facility];
+ struct destination *f = &destinations[destination];
ovs_rwlock_wrlock(&pattern_rwlock);
if (!f->default_pattern) {
ovs_rwlock_wrlock(&pattern_rwlock);
if (!f->default_pattern) {
ovs_rwlock_unlock(&pattern_rwlock);
}
ovs_rwlock_unlock(&pattern_rwlock);
}
-/* Sets the pattern for the given 'facility' to 'pattern'. */
+/* Sets the pattern for the given 'destination' to 'pattern'. */
-vlog_set_pattern(enum vlog_facility facility, const char *pattern)
+vlog_set_pattern(enum vlog_destination destination, const char *pattern)
- assert(facility < VLF_N_FACILITIES || facility == VLF_ANY_FACILITY);
- if (facility == VLF_ANY_FACILITY) {
- for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
- do_set_pattern(facility, pattern);
+ assert(destination < VLF_N_DESTINATIONS ||
+ destination == VLF_ANY_DESTINATION);
+ if (destination == VLF_ANY_DESTINATION) {
+ for (destination = 0; destination < VLF_N_DESTINATIONS;
+ destination++) {
+ do_set_pattern(destination, pattern);
- do_set_pattern(facility, pattern);
+ do_set_pattern(destination, pattern);
word = strtok_r(s, " ,:\t", &save_ptr);
if (word && !strcasecmp(word, "PATTERN")) {
word = strtok_r(s, " ,:\t", &save_ptr);
if (word && !strcasecmp(word, "PATTERN")) {
- enum vlog_facility facility;
+ enum vlog_destination destination;
word = strtok_r(NULL, " ,:\t", &save_ptr);
if (!word) {
word = strtok_r(NULL, " ,:\t", &save_ptr);
if (!word) {
- msg = xstrdup("missing facility");
+ msg = xstrdup("missing destination");
- facility = (!strcasecmp(word, "ANY")
- ? VLF_ANY_FACILITY
- : vlog_get_facility_val(word));
- if (facility == VLF_N_FACILITIES) {
- msg = xasprintf("unknown facility \"%s\"", word);
+ destination = (!strcasecmp(word, "ANY")
+ ? VLF_ANY_DESTINATION
+ : vlog_get_destination_val(word));
+ if (destination == VLF_N_DESTINATIONS) {
+ msg = xasprintf("unknown destination \"%s\"", word);
- vlog_set_pattern(facility, save_ptr);
+ vlog_set_pattern(destination, save_ptr);
} else {
struct vlog_module *module = NULL;
enum vlog_level level = VLL_N_LEVELS;
} else {
struct vlog_module *module = NULL;
enum vlog_level level = VLL_N_LEVELS;
- enum vlog_facility facility = VLF_N_FACILITIES;
+ enum vlog_destination destination = VLF_N_DESTINATIONS;
for (; word != NULL; word = strtok_r(NULL, " ,:\t", &save_ptr)) {
if (!strcasecmp(word, "ANY")) {
continue;
for (; word != NULL; word = strtok_r(NULL, " ,:\t", &save_ptr)) {
if (!strcasecmp(word, "ANY")) {
continue;
- } else if (vlog_get_facility_val(word) != VLF_N_FACILITIES) {
- if (facility != VLF_N_FACILITIES) {
- msg = xstrdup("cannot specify multiple facilities");
+ } else if (vlog_get_destination_val(word) != VLF_N_DESTINATIONS) {
+ if (destination != VLF_N_DESTINATIONS) {
+ msg = xstrdup("cannot specify multiple destinations");
- facility = vlog_get_facility_val(word);
+ destination = vlog_get_destination_val(word);
} else if (vlog_get_level_val(word) != VLL_N_LEVELS) {
if (level != VLL_N_LEVELS) {
msg = xstrdup("cannot specify multiple levels");
} else if (vlog_get_level_val(word) != VLL_N_LEVELS) {
if (level != VLL_N_LEVELS) {
msg = xstrdup("cannot specify multiple levels");
}
module = vlog_module_from_name(word);
} else {
}
module = vlog_module_from_name(word);
} else {
- msg = xasprintf("no facility, level, or module \"%s\"", word);
+ msg = xasprintf("no destination, level, or module \"%s\"",
+ word);
- if (facility == VLF_N_FACILITIES) {
- facility = VLF_ANY_FACILITY;
+ if (destination == VLF_N_DESTINATIONS) {
+ destination = VLF_ANY_DESTINATION;
}
if (level == VLL_N_LEVELS) {
level = VLL_DBG;
}
}
if (level == VLL_N_LEVELS) {
level = VLL_DBG;
}
- vlog_set_levels(module, facility, level);
+ vlog_set_levels(module, destination, level);
ovs_fatal(0, "processing \"%s\": %s", arg, msg);
}
} else {
ovs_fatal(0, "processing \"%s\": %s", arg, msg);
}
} else {
- vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_DBG);
+ vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_DBG);
}
unixctl_command_register(
}
unixctl_command_register(
- "vlog/set", "{spec | PATTERN:facility:pattern}",
+ "vlog/set", "{spec | PATTERN:destination:pattern}",
1, INT_MAX, vlog_unixctl_set, NULL);
unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list,
NULL);
1, INT_MAX, vlog_unixctl_set, NULL);
unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list,
NULL);
ovs_rwlock_rdlock(&pattern_rwlock);
if (log_to_console) {
ovs_rwlock_rdlock(&pattern_rwlock);
if (log_to_console) {
- format_log_message(module, level, facilities[VLF_CONSOLE].pattern,
- message, args, &s);
+ format_log_message(module, level,
+ destinations[VLF_CONSOLE].pattern, message,
+ args, &s);
ds_put_char(&s, '\n');
fputs(ds_cstr(&s), stderr);
}
ds_put_char(&s, '\n');
fputs(ds_cstr(&s), stderr);
}
char *save_ptr = NULL;
char *line;
char *save_ptr = NULL;
char *line;
- format_log_message(module, level, facilities[VLF_SYSLOG].pattern,
+ format_log_message(module, level, destinations[VLF_SYSLOG].pattern,
message, args, &s);
for (line = strtok_r(s.string, "\n", &save_ptr); line;
line = strtok_r(NULL, "\n", &save_ptr)) {
message, args, &s);
for (line = strtok_r(s.string, "\n", &save_ptr); line;
line = strtok_r(NULL, "\n", &save_ptr)) {
- format_log_message(module, level, facilities[VLF_FILE].pattern,
+ format_log_message(module, level, destinations[VLF_FILE].pattern,
message, args, &s);
ds_put_char(&s, '\n');
message, args, &s);
ds_put_char(&s, '\n');
/* Logs 'message' to 'module' at maximum verbosity, then exits with a failure
* exit code. Always writes the message to stderr, even if the console
/* Logs 'message' to 'module' at maximum verbosity, then exits with a failure
* exit code. Always writes the message to stderr, even if the console
- * facility is disabled.
+ * destination is disabled.
*
* Choose this function instead of vlog_abort_valist() if the daemon monitoring
* facility shouldn't automatically restart the current daemon. */
*
* Choose this function instead of vlog_abort_valist() if the daemon monitoring
* facility shouldn't automatically restart the current daemon. */
/* Logs 'message' to 'module' at maximum verbosity, then exits with a failure
* exit code. Always writes the message to stderr, even if the console
/* Logs 'message' to 'module' at maximum verbosity, then exits with a failure
* exit code. Always writes the message to stderr, even if the console
- * facility is disabled.
+ * destination is disabled.
*
* Choose this function instead of vlog_abort() if the daemon monitoring
* facility shouldn't automatically restart the current daemon. */
*
* Choose this function instead of vlog_abort() if the daemon monitoring
* facility shouldn't automatically restart the current daemon. */
}
/* Logs 'message' to 'module' at maximum verbosity, then calls abort(). Always
}
/* Logs 'message' to 'module' at maximum verbosity, then calls abort(). Always
- * writes the message to stderr, even if the console facility is disabled.
+ * writes the message to stderr, even if the console destination is disabled.
*
* Choose this function instead of vlog_fatal_valist() if the daemon monitoring
* facility should automatically restart the current daemon. */
*
* Choose this function instead of vlog_fatal_valist() if the daemon monitoring
* facility should automatically restart the current daemon. */
}
/* Logs 'message' to 'module' at maximum verbosity, then calls abort(). Always
}
/* Logs 'message' to 'module' at maximum verbosity, then calls abort(). Always
- * writes the message to stderr, even if the console facility is disabled.
+ * writes the message to stderr, even if the console destination is disabled.
*
* Choose this function instead of vlog_fatal() if the daemon monitoring
* facility should automatically restart the current daemon. */
*
* Choose this function instead of vlog_fatal() if the daemon monitoring
* facility should automatically restart the current daemon. */
.IQ "\fB\-\-verbose=\fR[\fIspec\fR]
.
Sets logging levels. Without any \fIspec\fR, sets the log level for
.IQ "\fB\-\-verbose=\fR[\fIspec\fR]
.
Sets logging levels. Without any \fIspec\fR, sets the log level for
-every module and facility to \fBdbg\fR. Otherwise, \fIspec\fR is a
+every module and destination to \fBdbg\fR. Otherwise, \fIspec\fR is a
list of words separated by spaces or commas or colons, up to one from
each category below:
.
list of words separated by spaces or commas or colons, up to one from
each category below:
.
Sets the maximum logging verbosity level, equivalent to
\fB\-\-verbose=dbg\fR.
.
Sets the maximum logging verbosity level, equivalent to
\fB\-\-verbose=dbg\fR.
.
-.IP "\fB\-vPATTERN:\fIfacility\fB:\fIpattern\fR"
-.IQ "\fB\-\-verbose=PATTERN:\fIfacility\fB:\fIpattern\fR"
-Sets the log pattern for \fIfacility\fR to \fIpattern\fR. Refer to
+.IP "\fB\-vPATTERN:\fIdestination\fB:\fIpattern\fR"
+.IQ "\fB\-\-verbose=PATTERN:\fIdestination\fB:\fIpattern\fR"
+Sets the log pattern for \fIdestination\fR to \fIpattern\fR. Refer to
\fBovs\-appctl\fR(8) for a description of the valid syntax for \fIpattern\fR.
.
.TP
\fBovs\-appctl\fR(8) for a description of the valid syntax for \fIpattern\fR.
.
.TP
import ovs.unixctl
import ovs.util
import ovs.unixctl
import ovs.util
-FACILITIES = {"console": "info", "file": "info", "syslog": "info"}
+DESTINATIONS = {"console": "info", "file": "info", "syslog": "info"}
PATTERNS = {
"console": "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m",
"file": "%D{%Y-%m-%dT%H:%M:%S.###Z}|%05N|%c%T|%p|%m",
PATTERNS = {
"console": "%D{%Y-%m-%dT%H:%M:%SZ}|%05N|%c%T|%p|%m",
"file": "%D{%Y-%m-%dT%H:%M:%S.###Z}|%05N|%c%T|%p|%m",
__inited = False
__msg_num = 0
__start_time = 0
__inited = False
__msg_num = 0
__start_time = 0
- __mfl = {} # Module -> facility -> level
+ __mfl = {} # Module -> destination -> level
__log_file = None
__file_handler = None
__log_patterns = PATTERNS
__log_file = None
__file_handler = None
__log_patterns = PATTERNS
assert not Vlog.__inited
self.name = name.lower()
if name not in Vlog.__mfl:
assert not Vlog.__inited
self.name = name.lower()
if name not in Vlog.__mfl:
- Vlog.__mfl[self.name] = FACILITIES.copy()
+ Vlog.__mfl[self.name] = DESTINATIONS.copy()
def __log(self, level, message, **kwargs):
if not Vlog.__inited:
def __log(self, level, message, **kwargs):
if not Vlog.__inited:
msg = self._build_message(message, f, level, msg_num)
logging.getLogger(f).log(level_num, msg, **kwargs)
msg = self._build_message(message, f, level, msg_num)
logging.getLogger(f).log(level_num, msg, **kwargs)
- def _build_message(self, message, facility, level, msg_num):
- pattern = self.__log_patterns[facility]
+ def _build_message(self, message, destination, level, msg_num):
+ pattern = self.__log_patterns[destination]
tmp = pattern
tmp = self._format_time(tmp)
tmp = pattern
tmp = self._format_time(tmp)
Vlog.__start_time = datetime.datetime.utcnow()
logging.raiseExceptions = False
Vlog.__log_file = log_file
Vlog.__start_time = datetime.datetime.utcnow()
logging.raiseExceptions = False
Vlog.__log_file = log_file
logger = logging.getLogger(f)
logger.setLevel(logging.DEBUG)
logger = logging.getLogger(f)
logger.setLevel(logging.DEBUG)
Vlog._unixctl_vlog_list, None)
@staticmethod
Vlog._unixctl_vlog_list, None)
@staticmethod
- def set_level(module, facility, level):
- """ Sets the log level of the 'module'-'facility' tuple to 'level'.
+ def set_level(module, destination, level):
+ """ Sets the log level of the 'module'-'destination' tuple to 'level'.
All three arguments are strings which are interpreted the same as
arguments to the --verbose flag. Should be called after all Vlog
objects have already been created."""
module = module.lower()
All three arguments are strings which are interpreted the same as
arguments to the --verbose flag. Should be called after all Vlog
objects have already been created."""
module = module.lower()
- facility = facility.lower()
+ destination = destination.lower()
- if facility != "any" and facility not in FACILITIES:
+ if destination != "any" and destination not in DESTINATIONS:
return
if module != "any" and module not in Vlog.__mfl:
return
if module != "any" and module not in Vlog.__mfl:
- if facility == "any":
- facilities = FACILITIES.keys()
+ if destination == "any":
+ destinations = DESTINATIONS.keys()
- facilities = [facility]
+ destinations = [destination]
Vlog.__mfl[m][f] = level
@staticmethod
Vlog.__mfl[m][f] = level
@staticmethod
- def set_pattern(facility, pattern):
- """ Sets the log pattern of the 'facility' to 'pattern' """
- facility = facility.lower()
- Vlog.__log_patterns[facility] = pattern
+ def set_pattern(destination, pattern):
+ """ Sets the log pattern of the 'destination' to 'pattern' """
+ destination = destination.lower()
+ Vlog.__log_patterns[destination] = pattern
@staticmethod
def set_levels_from_string(s):
module = None
level = None
@staticmethod
def set_levels_from_string(s):
module = None
level = None
words = re.split('[ :]', s)
if words[0] == "pattern":
try:
words = re.split('[ :]', s)
if words[0] == "pattern":
try:
- if words[1] in FACILITIES and words[2]:
+ if words[1] in DESTINATIONS and words[2]:
segments = [words[i] for i in range(2, len(words))]
pattern = "".join(segments)
Vlog.set_pattern(words[1], pattern)
return
else:
segments = [words[i] for i in range(2, len(words))]
pattern = "".join(segments)
Vlog.set_pattern(words[1], pattern)
return
else:
- return "Facility %s does not exist" % words[1]
+ return "Destination %s does not exist" % words[1]
- return "Please supply a valid pattern and facility"
+ return "Please supply a valid pattern and destination"
for word in [w.lower() for w in words]:
if word == "any":
pass
for word in [w.lower() for w in words]:
if word == "any":
pass
- elif word in FACILITIES:
- if facility:
- return "cannot specify multiple facilities"
- facility = word
+ elif word in DESTINATIONS:
+ if destination:
+ return "cannot specify multiple destinations"
+ destination = word
elif word in LEVELS:
if level:
return "cannot specify multiple levels"
elif word in LEVELS:
if level:
return "cannot specify multiple levels"
return "cannot specify multiple modules"
module = word
else:
return "cannot specify multiple modules"
module = word
else:
- return "no facility, level, or module \"%s\"" % word
+ return "no destination, level, or module \"%s\"" % word
- Vlog.set_level(module or "any", facility or "any", level or "any")
+ Vlog.set_level(module or "any", destination or "any", level or "any")
@staticmethod
def get_levels():
@staticmethod
def get_levels():
int old_time;
char line[128];
int old_time;
char line[128];
- vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_OFF);
+ vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_OFF);
now = 1000;
reconnect = reconnect_create(now);
now = 1000;
reconnect = reconnect_create(now);
test_vconn_main(int argc, char *argv[])
{
set_program_name(argv[0]);
test_vconn_main(int argc, char *argv[])
{
set_program_name(argv[0]);
- vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_EMER);
+ vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_EMER);
vlog_set_levels(NULL, VLF_CONSOLE, VLL_DBG);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_DBG);
fatal_ignore_sigpipe();
AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
- [no facility, level, or module "nonexistent"
+ [no destination, level, or module "nonexistent"
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
console syslog file
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
console syslog file
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
- [Please supply a valid pattern and facility
+ [Please supply a valid pattern and destination
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
- [Facility nonexistent does not exist
+ [Destination nonexistent does not exist
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
int error;
set_program_name(argv[0]);
int error;
set_program_name(argv[0]);
- vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_DBG);
+ vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_DBG);
error = nl_sock_create(NETLINK_ROUTE, &sock);
if (error) {
error = nl_sock_create(NETLINK_ROUTE, &sock);
if (error) {
.
.IP "\fBoff\fR"
No message is ever logged at this level, so setting a logging
.
.IP "\fBoff\fR"
No message is ever logged at this level, so setting a logging
-facility's log level to \fBoff\fR disables logging to that facility.
+destination's log level to \fBoff\fR disables logging to that destination.
.
.PP
The following log levels, in order of descending severity, are
.
.PP
The following log levels, in order of descending severity, are
.
.IP "\fBvlog/set\fR [\fIspec\fR]"
Sets logging levels. Without any \fIspec\fR, sets the log level for
.
.IP "\fBvlog/set\fR [\fIspec\fR]"
Sets logging levels. Without any \fIspec\fR, sets the log level for
-every module and facility to \fBdbg\fR. Otherwise, \fIspec\fR is a
+every module and destination to \fBdbg\fR. Otherwise, \fIspec\fR is a
list of words separated by spaces or commas or colons, up to one from
each category below:
.
list of words separated by spaces or commas or colons, up to one from
each category below:
.
For compatibility with older versions of OVS, \fBany\fR is accepted as
a word but has no effect.
.
For compatibility with older versions of OVS, \fBany\fR is accepted as
a word but has no effect.
.
-.IP "\fBvlog/set PATTERN:\fIfacility\fB:\fIpattern\fR"
-Sets the log pattern for \fIfacility\fR to \fIpattern\fR. Each time a
-message is logged to \fIfacility\fR, \fIpattern\fR determines the
+.IP "\fBvlog/set PATTERN:\fIdestination\fB:\fIpattern\fR"
+Sets the log pattern for \fIdestination\fR to \fIpattern\fR. Each time a
+message is logged to \fIdestination\fR, \fIpattern\fR determines the
message's formatting. Most characters in \fIpattern\fR are copied
literally to the log, but special escapes beginning with \fB%\fR are
expanded as follows:
message's formatting. Most characters in \fIpattern\fR are copied
literally to the log, but special escapes beginning with \fB%\fR are
expanded as follows:
vlog/set [SPEC]\n\
Set log levels as detailed in SPEC, which may include:\n\
A valid module name (all modules, by default)\n\
vlog/set [SPEC]\n\
Set log levels as detailed in SPEC, which may include:\n\
A valid module name (all modules, by default)\n\
- 'syslog', 'console', 'file' (all facilities, by default))\n\
+ 'syslog', 'console', 'file' (all destinations, by default))\n\
'off', 'emer', 'err', 'warn', 'info', or 'dbg' ('dbg', bydefault)\n\
vlog/reopen Make the program reopen its log file\n\
Other options:\n\
'off', 'emer', 'err', 'warn', 'info', or 'dbg' ('dbg', bydefault)\n\
vlog/reopen Make the program reopen its log file\n\
Other options:\n\
main(int argc, char *argv[])
{
set_program_name(argv[0]);
main(int argc, char *argv[])
{
set_program_name(argv[0]);
- vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_EMER);
+ vlog_set_levels(NULL, VLF_ANY_DESTINATION, VLL_EMER);
parse_options(argc, argv);
run_command(argc - optind, argv + optind, get_all_commands());
return 0;
parse_options(argc, argv);
run_command(argc - optind, argv + optind, get_all_commands());
return 0;
# complex completion check - vlog/set
# complex completion check - vlog/set
-# vlog/set {spec | PATTERN:facility:pattern}
+# vlog/set {spec | PATTERN:destination:pattern}
# test non expandable arguments
reset_globals
# test non expandable arguments
reset_globals
# check the top level completion.
COMP_OUTPUT="$(bash ovs-command-compgen.bash debug ovs-appctl vlog/set TAB 2>&1)"
TMP="$(get_argument_expansion "$COMP_OUTPUT" | sed -e 's/[ \t]*$//')"
# check the top level completion.
COMP_OUTPUT="$(bash ovs-command-compgen.bash debug ovs-appctl vlog/set TAB 2>&1)"
TMP="$(get_argument_expansion "$COMP_OUTPUT" | sed -e 's/[ \t]*$//')"
- EXPECT="$(generate_expect_completions "PATTERN:facility:pattern" "")
+ EXPECT="$(generate_expect_completions "PATTERN:destination:pattern" "")
$(generate_expect_completions "spec" "")"
if [ "$TMP" != "$EXPECT" ]; then
print_error "1" "$TMP" "$EXPECT"
$(generate_expect_completions "spec" "")"
if [ "$TMP" != "$EXPECT" ]; then
print_error "1" "$TMP" "$EXPECT"
COMP_OUTPUT="$(bash ovs-command-compgen.bash debug ovs-appctl vlog/set abcd TAB 2>&1)"
TMP="$(sed -e '/./,$!d' <<< "$COMP_OUTPUT")"
EXPECT="Command format:
COMP_OUTPUT="$(bash ovs-command-compgen.bash debug ovs-appctl vlog/set abcd TAB 2>&1)"
TMP="$(sed -e '/./,$!d' <<< "$COMP_OUTPUT")"
EXPECT="Command format:
-vlog/set {spec | PATTERN:facility:pattern}"
+vlog/set {spec | PATTERN:destination:pattern}"
if [ "$TMP" != "$EXPECT" ]; then
print_error "3" "$TMP" "$EXPECT"
TEST_RESULT=fail
if [ "$TMP" != "$EXPECT" ]; then
print_error "3" "$TMP" "$EXPECT"
TEST_RESULT=fail
-print_result "negative test - do not match on nested option" "$TEST_RESULT"
\ No newline at end of file
+print_result "negative test - do not match on nested option" "$TEST_RESULT"
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
- vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
+ vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
ovsrec_init();
/* Log our arguments. This is often valuable for debugging systems. */
ovsrec_init();
/* Log our arguments. This is often valuable for debugging systems. */
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
set_program_name(argv[0]);
fatal_ignore_sigpipe();
vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
- vlog_set_levels(&VLM_reconnect, VLF_ANY_FACILITY, VLL_WARN);
+ vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
vteprec_init();
/* Log our arguments. This is often valuable for debugging systems. */
vteprec_init();
/* Log our arguments. This is often valuable for debugging systems. */