vlog: Add a new log level "off".
[sliver-openvswitch.git] / lib / vlog.c
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <config.h>
18 #include "vlog.h"
19 #include <assert.h>
20 #include <ctype.h>
21 #include <errno.h>
22 #include <stdarg.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <sys/types.h>
26 #include <syslog.h>
27 #include <time.h>
28 #include <unistd.h>
29 #include "dirs.h"
30 #include "dynamic-string.h"
31 #include "sat-math.h"
32 #include "svec.h"
33 #include "timeval.h"
34 #include "unixctl.h"
35 #include "util.h"
36
37 VLOG_DEFINE_THIS_MODULE(vlog);
38
39 /* Name for each logging level. */
40 static const char *level_names[VLL_N_LEVELS] = {
41 #define VLOG_LEVEL(NAME, SYSLOG_LEVEL) #NAME,
42     VLOG_LEVELS
43 #undef VLOG_LEVEL
44 };
45
46 /* Syslog value for each logging level. */
47 static int syslog_levels[VLL_N_LEVELS] = {
48 #define VLOG_LEVEL(NAME, SYSLOG_LEVEL) SYSLOG_LEVEL,
49     VLOG_LEVELS
50 #undef VLOG_LEVEL
51 };
52
53 /* The log modules. */
54 #if USE_LINKER_SECTIONS
55 extern struct vlog_module *__start_vlog_modules[];
56 extern struct vlog_module *__stop_vlog_modules[];
57 #define vlog_modules __start_vlog_modules
58 #define n_vlog_modules (__stop_vlog_modules - __start_vlog_modules)
59 #else
60 #define VLOG_MODULE VLOG_DEFINE_MODULE__
61 #include "vlog-modules.def"
62 #undef VLOG_MODULE
63
64 struct vlog_module *vlog_modules[] = {
65 #define VLOG_MODULE(NAME) &VLM_##NAME,
66 #include "vlog-modules.def"
67 #undef VLOG_MODULE
68 };
69 #define n_vlog_modules ARRAY_SIZE(vlog_modules)
70 #endif
71
72 /* Information about each facility. */
73 struct facility {
74     const char *name;           /* Name. */
75     char *pattern;              /* Current pattern. */
76     bool default_pattern;       /* Whether current pattern is the default. */
77 };
78 static struct facility facilities[VLF_N_FACILITIES] = {
79 #define VLOG_FACILITY(NAME, PATTERN) {#NAME, PATTERN, true},
80     VLOG_FACILITIES
81 #undef VLOG_FACILITY
82 };
83
84 /* Time at which vlog was initialized, in milliseconds. */
85 static long long int boot_time;
86
87 /* VLF_FILE configuration. */
88 static char *log_file_name;
89 static FILE *log_file;
90
91 /* vlog initialized? */
92 static bool vlog_inited;
93
94 static void format_log_message(const struct vlog_module *, enum vlog_level,
95                                enum vlog_facility, unsigned int msg_num,
96                                const char *message, va_list, struct ds *)
97     PRINTF_FORMAT(5, 0);
98
99 /* Searches the 'n_names' in 'names'.  Returns the index of a match for
100  * 'target', or 'n_names' if no name matches. */
101 static size_t
102 search_name_array(const char *target, const char **names, size_t n_names)
103 {
104     size_t i;
105
106     for (i = 0; i < n_names; i++) {
107         assert(names[i]);
108         if (!strcasecmp(names[i], target)) {
109             break;
110         }
111     }
112     return i;
113 }
114
115 /* Returns the name for logging level 'level'. */
116 const char *
117 vlog_get_level_name(enum vlog_level level)
118 {
119     assert(level < VLL_N_LEVELS);
120     return level_names[level];
121 }
122
123 /* Returns the logging level with the given 'name', or VLL_N_LEVELS if 'name'
124  * is not the name of a logging level. */
125 enum vlog_level
126 vlog_get_level_val(const char *name)
127 {
128     return search_name_array(name, level_names, ARRAY_SIZE(level_names));
129 }
130
131 /* Returns the name for logging facility 'facility'. */
132 const char *
133 vlog_get_facility_name(enum vlog_facility facility)
134 {
135     assert(facility < VLF_N_FACILITIES);
136     return facilities[facility].name;
137 }
138
139 /* Returns the logging facility named 'name', or VLF_N_FACILITIES if 'name' is
140  * not the name of a logging facility. */
141 enum vlog_facility
142 vlog_get_facility_val(const char *name)
143 {
144     size_t i;
145
146     for (i = 0; i < VLF_N_FACILITIES; i++) {
147         if (!strcasecmp(facilities[i].name, name)) {
148             break;
149         }
150     }
151     return i;
152 }
153
154 /* Returns the name for logging module 'module'. */
155 const char *
156 vlog_get_module_name(const struct vlog_module *module)
157 {
158     return module->name;
159 }
160
161 /* Returns the logging module named 'name', or NULL if 'name' is not the name
162  * of a logging module. */
163 struct vlog_module *
164 vlog_module_from_name(const char *name)
165 {
166     struct vlog_module **mp;
167
168     for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) {
169         if (!strcasecmp(name, (*mp)->name)) {
170             return *mp;
171         }
172     }
173     return NULL;
174 }
175
176 /* Returns the current logging level for the given 'module' and 'facility'. */
177 enum vlog_level
178 vlog_get_level(const struct vlog_module *module, enum vlog_facility facility)
179 {
180     assert(facility < VLF_N_FACILITIES);
181     return module->levels[facility];
182 }
183
184 static void
185 update_min_level(struct vlog_module *module)
186 {
187     enum vlog_facility facility;
188
189     module->min_level = VLL_OFF;
190     for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
191         if (log_file || facility != VLF_FILE) {
192             enum vlog_level level = module->levels[facility];
193             if (level > module->min_level) {
194                 module->min_level = level;
195             }
196         }
197     }
198 }
199
200 static void
201 set_facility_level(enum vlog_facility facility, struct vlog_module *module,
202                    enum vlog_level level)
203 {
204     assert(facility >= 0 && facility < VLF_N_FACILITIES);
205     assert(level < VLL_N_LEVELS);
206
207     if (!module) {
208         struct vlog_module **mp;
209
210         for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) {
211             (*mp)->levels[facility] = level;
212             update_min_level(*mp);
213         }
214     } else {
215         module->levels[facility] = level;
216         update_min_level(module);
217     }
218 }
219
220 /* Sets the logging level for the given 'module' and 'facility' to 'level'.  A
221  * null 'module' or a 'facility' of VLF_ANY_FACILITY is treated as a wildcard
222  * across all modules or facilities, respectively. */
223 void
224 vlog_set_levels(struct vlog_module *module, enum vlog_facility facility,
225                 enum vlog_level level)
226 {
227     assert(facility < VLF_N_FACILITIES || facility == VLF_ANY_FACILITY);
228     if (facility == VLF_ANY_FACILITY) {
229         for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
230             set_facility_level(facility, module, level);
231         }
232     } else {
233         set_facility_level(facility, module, level);
234     }
235 }
236
237 static void
238 do_set_pattern(enum vlog_facility facility, const char *pattern)
239 {
240     struct facility *f = &facilities[facility];
241     if (!f->default_pattern) {
242         free(f->pattern);
243     } else {
244         f->default_pattern = false;
245     }
246     f->pattern = xstrdup(pattern);
247 }
248
249 /* Sets the pattern for the given 'facility' to 'pattern'. */
250 void
251 vlog_set_pattern(enum vlog_facility facility, const char *pattern)
252 {
253     assert(facility < VLF_N_FACILITIES || facility == VLF_ANY_FACILITY);
254     if (facility == VLF_ANY_FACILITY) {
255         for (facility = 0; facility < VLF_N_FACILITIES; facility++) {
256             do_set_pattern(facility, pattern);
257         }
258     } else {
259         do_set_pattern(facility, pattern);
260     }
261 }
262
263 /* Returns the name of the log file used by VLF_FILE, or a null pointer if no
264  * log file has been set.  (A non-null return value does not assert that the
265  * named log file is in use: if vlog_set_log_file() or vlog_reopen_log_file()
266  * fails, it still sets the log file name.) */
267 const char *
268 vlog_get_log_file(void)
269 {
270     return log_file_name;
271 }
272
273 /* Sets the name of the log file used by VLF_FILE to 'file_name', or to the
274  * default file name if 'file_name' is null.  Returns 0 if successful,
275  * otherwise a positive errno value. */
276 int
277 vlog_set_log_file(const char *file_name)
278 {
279     char *old_log_file_name;
280     struct vlog_module **mp;
281     int error;
282
283     /* Close old log file. */
284     if (log_file) {
285         VLOG_INFO("closing log file");
286         fclose(log_file);
287         log_file = NULL;
288     }
289
290     /* Update log file name and free old name.  The ordering is important
291      * because 'file_name' might be 'log_file_name' or some suffix of it. */
292     old_log_file_name = log_file_name;
293     log_file_name = (file_name
294                      ? xstrdup(file_name)
295                      : xasprintf("%s/%s.log", ovs_logdir(), program_name));
296     free(old_log_file_name);
297     file_name = NULL;           /* Might have been freed. */
298
299     /* Open new log file and update min_levels[] to reflect whether we actually
300      * have a log_file. */
301     log_file = fopen(log_file_name, "a");
302     for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) {
303         update_min_level(*mp);
304     }
305
306     /* Log success or failure. */
307     if (!log_file) {
308         VLOG_WARN("failed to open %s for logging: %s",
309                   log_file_name, strerror(errno));
310         error = errno;
311     } else {
312         VLOG_INFO("opened log file %s", log_file_name);
313         error = 0;
314     }
315
316     return error;
317 }
318
319 /* Closes and then attempts to re-open the current log file.  (This is useful
320  * just after log rotation, to ensure that the new log file starts being used.)
321  * Returns 0 if successful, otherwise a positive errno value. */
322 int
323 vlog_reopen_log_file(void)
324 {
325     return log_file_name ? vlog_set_log_file(log_file_name) : 0;
326 }
327
328 /* Set debugging levels:
329  *
330  *  mod[:facility[:level]] mod2[:facility[:level]] ...
331  *
332  * Return null if successful, otherwise an error message that the caller must
333  * free().
334  */
335 char *
336 vlog_set_levels_from_string(const char *s_)
337 {
338     char *save_ptr = NULL;
339     char *s = xstrdup(s_);
340     char *module, *facility;
341
342     for (module = strtok_r(s, ": \t", &save_ptr); module != NULL;
343          module = strtok_r(NULL, ": \t", &save_ptr)) {
344         struct vlog_module *e_module;
345         enum vlog_facility e_facility;
346
347         facility = strtok_r(NULL, ":", &save_ptr);
348
349         if (!facility || !strcmp(facility, "ANY")) {
350             e_facility = VLF_ANY_FACILITY;
351         } else {
352             e_facility = vlog_get_facility_val(facility);
353             if (e_facility >= VLF_N_FACILITIES) {
354                 char *msg = xasprintf("unknown facility \"%s\"", facility);
355                 free(s);
356                 return msg;
357             }
358         }
359
360         if (!strcmp(module, "PATTERN")) {
361             vlog_set_pattern(e_facility, save_ptr);
362             break;
363         } else {
364             char *level;
365             enum vlog_level e_level;
366
367             if (!strcmp(module, "ANY")) {
368                 e_module = NULL;
369             } else {
370                 e_module = vlog_module_from_name(module);
371                 if (!e_module) {
372                     char *msg = xasprintf("unknown module \"%s\"", module);
373                     free(s);
374                     return msg;
375                 }
376             }
377
378             level = strtok_r(NULL, ":", &save_ptr);
379             e_level = level ? vlog_get_level_val(level) : VLL_DBG;
380             if (e_level >= VLL_N_LEVELS) {
381                 char *msg = xasprintf("unknown level \"%s\"", level);
382                 free(s);
383                 return msg;
384             }
385
386             vlog_set_levels(e_module, e_facility, e_level);
387         }
388     }
389     free(s);
390     return NULL;
391 }
392
393 /* If 'arg' is null, configure maximum verbosity.  Otherwise, sets
394  * configuration according to 'arg' (see vlog_set_levels_from_string()). */
395 void
396 vlog_set_verbosity(const char *arg)
397 {
398     if (arg) {
399         char *msg = vlog_set_levels_from_string(arg);
400         if (msg) {
401             ovs_fatal(0, "processing \"%s\": %s", arg, msg);
402         }
403     } else {
404         vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_DBG);
405     }
406 }
407
408 static void
409 vlog_unixctl_set(struct unixctl_conn *conn,
410                  const char *args, void *aux OVS_UNUSED)
411 {
412     char *msg = vlog_set_levels_from_string(args);
413     unixctl_command_reply(conn, msg ? 501 : 202, msg);
414     free(msg);
415 }
416
417 static void
418 vlog_unixctl_list(struct unixctl_conn *conn,
419                   const char *args OVS_UNUSED, void *aux OVS_UNUSED)
420 {
421     char *msg = vlog_get_levels();
422     unixctl_command_reply(conn, 200, msg);
423     free(msg);
424 }
425
426 static void
427 vlog_unixctl_reopen(struct unixctl_conn *conn,
428                     const char *args OVS_UNUSED, void *aux OVS_UNUSED)
429 {
430     if (log_file_name) {
431         int error = vlog_reopen_log_file();
432         if (error) {
433             unixctl_command_reply(conn, 503, strerror(errno));
434         } else {
435             unixctl_command_reply(conn, 202, NULL);
436         }
437     } else {
438         unixctl_command_reply(conn, 403, "Logging to file not configured");
439     }
440 }
441
442 /* Initializes the logging subsystem and registers its unixctl server
443  * commands. */
444 void
445 vlog_init(void)
446 {
447     time_t now;
448
449     if (vlog_inited) {
450         return;
451     }
452     vlog_inited = true;
453
454     openlog(program_name, LOG_NDELAY, LOG_DAEMON);
455
456     boot_time = time_msec();
457     now = time_wall();
458     if (now < 0) {
459         struct tm tm;
460         char s[128];
461
462         localtime_r(&now, &tm);
463         strftime(s, sizeof s, "%a, %d %b %Y %H:%M:%S %z", &tm);
464         VLOG_ERR("current time is negative: %s (%ld)", s, (long int) now);
465     }
466
467     unixctl_command_register("vlog/set", vlog_unixctl_set, NULL);
468     unixctl_command_register("vlog/list", vlog_unixctl_list, NULL);
469     unixctl_command_register("vlog/reopen", vlog_unixctl_reopen, NULL);
470 }
471
472 /* Closes the logging subsystem. */
473 void
474 vlog_exit(void)
475 {
476     if (vlog_inited) {
477         closelog();
478         vlog_inited = false;
479     }
480 }
481
482 /* Print the current logging level for each module. */
483 char *
484 vlog_get_levels(void)
485 {
486     struct ds s = DS_EMPTY_INITIALIZER;
487     struct vlog_module **mp;
488     struct svec lines = SVEC_EMPTY_INITIALIZER;
489     char *line;
490     size_t i;
491
492     ds_put_format(&s, "                 console    syslog    file\n");
493     ds_put_format(&s, "                 -------    ------    ------\n");
494
495     for (mp = vlog_modules; mp < &vlog_modules[n_vlog_modules]; mp++) {
496         line = xasprintf("%-16s  %4s       %4s       %4s\n",
497            vlog_get_module_name(*mp),
498            vlog_get_level_name(vlog_get_level(*mp, VLF_CONSOLE)),
499            vlog_get_level_name(vlog_get_level(*mp, VLF_SYSLOG)),
500            vlog_get_level_name(vlog_get_level(*mp, VLF_FILE)));
501         svec_add_nocopy(&lines, line);
502     }
503
504     svec_sort(&lines);
505     SVEC_FOR_EACH (i, line, &lines) {
506         ds_put_cstr(&s, line);
507     }
508     svec_destroy(&lines);
509
510     return ds_cstr(&s);
511 }
512
513 /* Returns true if a log message emitted for the given 'module' and 'level'
514  * would cause some log output, false if that module and level are completely
515  * disabled. */
516 bool
517 vlog_is_enabled(const struct vlog_module *module, enum vlog_level level)
518 {
519     return module->min_level >= level;
520 }
521
522 static const char *
523 fetch_braces(const char *p, const char *def, char *out, size_t out_size)
524 {
525     if (*p == '{') {
526         size_t n = strcspn(p + 1, "}");
527         size_t n_copy = MIN(n, out_size - 1);
528         memcpy(out, p + 1, n_copy);
529         out[n_copy] = '\0';
530         p += n + 2;
531     } else {
532         ovs_strlcpy(out, def, out_size);
533     }
534     return p;
535 }
536
537 static void
538 format_log_message(const struct vlog_module *module, enum vlog_level level,
539                    enum vlog_facility facility, unsigned int msg_num,
540                    const char *message, va_list args_, struct ds *s)
541 {
542     char tmp[128];
543     va_list args;
544     const char *p;
545
546     ds_clear(s);
547     for (p = facilities[facility].pattern; *p != '\0'; ) {
548         enum { LEFT, RIGHT } justify = RIGHT;
549         int pad = '0';
550         size_t length, field, used;
551
552         if (*p != '%') {
553             ds_put_char(s, *p++);
554             continue;
555         }
556
557         p++;
558         if (*p == '-') {
559             justify = LEFT;
560             p++;
561         }
562         if (*p == '0') {
563             pad = '0';
564             p++;
565         }
566         field = 0;
567         while (isdigit((unsigned char)*p)) {
568             field = (field * 10) + (*p - '0');
569             p++;
570         }
571
572         length = s->length;
573         switch (*p++) {
574         case 'A':
575             ds_put_cstr(s, program_name);
576             break;
577         case 'c':
578             p = fetch_braces(p, "", tmp, sizeof tmp);
579             ds_put_cstr(s, vlog_get_module_name(module));
580             break;
581         case 'd':
582             p = fetch_braces(p, "%Y-%m-%d %H:%M:%S", tmp, sizeof tmp);
583             ds_put_strftime(s, tmp, NULL);
584             break;
585         case 'm':
586             /* Format user-supplied log message and trim trailing new-lines. */
587             length = s->length;
588             va_copy(args, args_);
589             ds_put_format_valist(s, message, args);
590             va_end(args);
591             while (s->length > length && s->string[s->length - 1] == '\n') {
592                 s->length--;
593             }
594             break;
595         case 'N':
596             ds_put_format(s, "%u", msg_num);
597             break;
598         case 'n':
599             ds_put_char(s, '\n');
600             break;
601         case 'p':
602             ds_put_cstr(s, vlog_get_level_name(level));
603             break;
604         case 'P':
605             ds_put_format(s, "%ld", (long int) getpid());
606             break;
607         case 'r':
608             ds_put_format(s, "%lld", time_msec() - boot_time);
609             break;
610         default:
611             ds_put_char(s, p[-1]);
612             break;
613         }
614         used = s->length - length;
615         if (used < field) {
616             size_t n_pad = field - used;
617             if (justify == RIGHT) {
618                 ds_put_uninit(s, n_pad);
619                 memmove(&s->string[length + n_pad], &s->string[length], used);
620                 memset(&s->string[length], pad, n_pad);
621             } else {
622                 ds_put_char_multiple(s, pad, n_pad);
623             }
624         }
625     }
626 }
627
628 /* Writes 'message' to the log at the given 'level' and as coming from the
629  * given 'module'.
630  *
631  * Guaranteed to preserve errno. */
632 void
633 vlog_valist(const struct vlog_module *module, enum vlog_level level,
634             const char *message, va_list args)
635 {
636     bool log_to_console = module->levels[VLF_CONSOLE] >= level;
637     bool log_to_syslog = module->levels[VLF_SYSLOG] >= level;
638     bool log_to_file = module->levels[VLF_FILE] >= level && log_file;
639     if (log_to_console || log_to_syslog || log_to_file) {
640         int save_errno = errno;
641         static unsigned int msg_num;
642         struct ds s;
643
644         vlog_init();
645
646         ds_init(&s);
647         ds_reserve(&s, 1024);
648         msg_num++;
649
650         if (log_to_console) {
651             format_log_message(module, level, VLF_CONSOLE, msg_num,
652                                message, args, &s);
653             ds_put_char(&s, '\n');
654             fputs(ds_cstr(&s), stderr);
655         }
656
657         if (log_to_syslog) {
658             int syslog_level = syslog_levels[level];
659             char *save_ptr = NULL;
660             char *line;
661
662             format_log_message(module, level, VLF_SYSLOG, msg_num,
663                                message, args, &s);
664             for (line = strtok_r(s.string, "\n", &save_ptr); line;
665                  line = strtok_r(NULL, "\n", &save_ptr)) {
666                 syslog(syslog_level, "%s", line);
667             }
668         }
669
670         if (log_to_file) {
671             format_log_message(module, level, VLF_FILE, msg_num,
672                                message, args, &s);
673             ds_put_char(&s, '\n');
674             fputs(ds_cstr(&s), log_file);
675             fflush(log_file);
676         }
677
678         ds_destroy(&s);
679         errno = save_errno;
680     }
681 }
682
683 void
684 vlog(const struct vlog_module *module, enum vlog_level level,
685      const char *message, ...)
686 {
687     va_list args;
688
689     va_start(args, message);
690     vlog_valist(module, level, message, args);
691     va_end(args);
692 }
693
694 void
695 vlog_fatal_valist(const struct vlog_module *module_,
696                   const char *message, va_list args)
697 {
698     struct vlog_module *module = (struct vlog_module *) module_;
699
700     /* Don't log this message to the console to avoid redundancy with the
701      * message written by the later ovs_fatal_valist(). */
702     module->levels[VLF_CONSOLE] = VLL_OFF;
703
704     vlog_valist(module, VLL_EMER, message, args);
705     ovs_fatal_valist(0, message, args);
706 }
707
708 void
709 vlog_fatal(const struct vlog_module *module, const char *message, ...)
710 {
711     va_list args;
712
713     va_start(args, message);
714     vlog_fatal_valist(module, message, args);
715     va_end(args);
716 }
717
718 bool
719 vlog_should_drop(const struct vlog_module *module, enum vlog_level level,
720                  struct vlog_rate_limit *rl)
721 {
722     if (!vlog_is_enabled(module, level)) {
723         return true;
724     }
725
726     if (rl->tokens < VLOG_MSG_TOKENS) {
727         time_t now = time_now();
728         if (rl->last_fill > now) {
729             /* Last filled in the future?  Time must have gone backward, or
730              * 'rl' has not been used before. */
731             rl->tokens = rl->burst;
732         } else if (rl->last_fill < now) {
733             unsigned int add = sat_mul(rl->rate, now - rl->last_fill);
734             unsigned int tokens = sat_add(rl->tokens, add);
735             rl->tokens = MIN(tokens, rl->burst);
736             rl->last_fill = now;
737         }
738         if (rl->tokens < VLOG_MSG_TOKENS) {
739             if (!rl->n_dropped) {
740                 rl->first_dropped = now;
741             }
742             rl->last_dropped = now;
743             rl->n_dropped++;
744             return true;
745         }
746     }
747     rl->tokens -= VLOG_MSG_TOKENS;
748
749     if (rl->n_dropped) {
750         time_t now = time_now();
751         unsigned int first_dropped_elapsed = now - rl->first_dropped;
752         unsigned int last_dropped_elapsed = now - rl->last_dropped;
753
754         vlog(module, level,
755              "Dropped %u log messages in last %u seconds (most recently, "
756              "%u seconds ago) due to excessive rate",
757              rl->n_dropped, first_dropped_elapsed, last_dropped_elapsed);
758
759         rl->n_dropped = 0;
760     }
761     return false;
762 }
763
764 void
765 vlog_rate_limit(const struct vlog_module *module, enum vlog_level level,
766                 struct vlog_rate_limit *rl, const char *message, ...)
767 {
768     if (!vlog_should_drop(module, level, rl)) {
769         va_list args;
770
771         va_start(args, message);
772         vlog_valist(module, level, message, args);
773         va_end(args);
774     }
775 }
776
777 void
778 vlog_usage(void)
779 {
780     printf("\nLogging options:\n"
781            "  -v, --verbose=MODULE[:FACILITY[:LEVEL]]  set logging levels\n"
782            "  -v, --verbose           set maximum verbosity level\n"
783            "  --log-file[=FILE]       enable logging to specified FILE\n"
784            "                          (default: %s/%s.log)\n",
785            ovs_logdir(), program_name);
786 }