#include "unixctl.h"
#include "util.h"
-VLOG_DEFINE_THIS_MODULE(vlog)
+VLOG_DEFINE_THIS_MODULE(vlog);
/* Name for each logging level. */
static const char *level_names[VLL_N_LEVELS] = {
/* Searches the 'n_names' in 'names'. Returns the index of a match for
* 'target', or 'n_names' if no name matches. */
static size_t
-search_name_array(const char *target, const char **names, size_t n_names)
+search_name_array(const char *target, const char **names, size_t n_names)
{
size_t i;
/* Returns the logging level with the given 'name', or VLL_N_LEVELS if 'name'
* is not the name of a logging level. */
enum vlog_level
-vlog_get_level_val(const char *name)
+vlog_get_level_val(const char *name)
{
return search_name_array(name, level_names, ARRAY_SIZE(level_names));
}
/* Returns the name for logging facility 'facility'. */
const char *
-vlog_get_facility_name(enum vlog_facility facility)
+vlog_get_facility_name(enum vlog_facility facility)
{
assert(facility < VLF_N_FACILITIES);
return facilities[facility].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)
+vlog_get_facility_val(const char *name)
{
size_t i;
/* Returns the current logging level for the given 'module' and 'facility'. */
enum vlog_level
-vlog_get_level(const struct vlog_module *module, enum vlog_facility facility)
+vlog_get_level(const struct vlog_module *module, enum vlog_facility facility)
{
assert(facility < VLF_N_FACILITIES);
return module->levels[facility];
for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
if (log_file || facility != VLF_FILE) {
enum vlog_level level = module->levels[facility];
- if (level < module->min_level) {
+ if (level > module->min_level) {
module->min_level = level;
}
}
* across all modules or facilities, respectively. */
void
vlog_set_levels(struct vlog_module *module, enum vlog_facility facility,
- enum vlog_level level)
+ enum vlog_level level)
{
assert(facility < VLF_N_FACILITIES || facility == VLF_ANY_FACILITY);
if (facility == VLF_ANY_FACILITY) {
}
static void
-do_set_pattern(enum vlog_facility facility, const char *pattern)
+do_set_pattern(enum vlog_facility facility, const char *pattern)
{
struct facility *f = &facilities[facility];
if (!f->default_pattern) {
old_log_file_name = log_file_name;
log_file_name = (file_name
? xstrdup(file_name)
- : xasprintf("%s/%s.log", ovs_logdir, program_name));
+ : xasprintf("%s/%s.log", ovs_logdir(), program_name));
free(old_log_file_name);
file_name = NULL; /* Might have been freed. */
}
}
-/* Initializes the logging subsystem. */
+/* Initializes the logging subsystem and registers its unixctl server
+ * commands. */
void
-vlog_init(void)
+vlog_init(void)
{
time_t now;
/* Closes the logging subsystem. */
void
-vlog_exit(void)
+vlog_exit(void)
{
if (vlog_inited) {
closelog();
}
void
-vlog_usage(void)
+vlog_usage(void)
{
printf("\nLogging options:\n"
" -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n"
" -v, --verbose set maximum verbosity level\n"
" --log-file[=FILE] enable logging to specified FILE\n"
" (default: %s/%s.log)\n",
- ovs_logdir, program_name);
+ ovs_logdir(), program_name);
}