+ static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+
+ if (ovsthread_once_start(&once)) {
+ long long int now;
+ int facility;
+ bool print_syslog_target_deprecation;
+
+ /* Do initialization work that needs to be done before any logging
+ * occurs. We want to keep this really minimal because any attempt to
+ * log anything before calling ovsthread_once_done() will deadlock. */
+ atomic_read_explicit(&log_facility, &facility, memory_order_relaxed);
+ if (!syslogger) {
+ syslogger = syslog_libc_create();
+ }
+ syslogger->class->openlog(syslogger, facility ? facility : LOG_DAEMON);
+ ovsthread_once_done(&once);
+
+ /* Now do anything that we want to happen only once but doesn't have to
+ * finish before we start logging. */
+
+ now = time_wall_msec();
+ if (now < 0) {
+ char *s = xastrftime_msec("%a, %d %b %Y %H:%M:%S", now, true);
+ VLOG_ERR("current time is negative: %s (%lld)", s, now);
+ free(s);
+ }
+
+ unixctl_command_register(
+ "vlog/set", "{spec | PATTERN:destination:pattern}",
+ 1, INT_MAX, vlog_unixctl_set, NULL);
+ unixctl_command_register("vlog/list", "", 0, 0, vlog_unixctl_list,
+ NULL);
+ unixctl_command_register("vlog/list-pattern", "", 0, 0,
+ vlog_unixctl_list_pattern, NULL);
+ unixctl_command_register("vlog/enable-rate-limit", "[module]...",
+ 0, INT_MAX, vlog_enable_rate_limit, NULL);
+ unixctl_command_register("vlog/disable-rate-limit", "[module]...",
+ 0, INT_MAX, vlog_disable_rate_limit, NULL);
+ unixctl_command_register("vlog/reopen", "", 0, 0,
+ vlog_unixctl_reopen, NULL);
+ unixctl_command_register("vlog/close", "", 0, 0,
+ vlog_unixctl_close, NULL);
+
+ ovs_rwlock_rdlock(&pattern_rwlock);
+ print_syslog_target_deprecation = syslog_fd >= 0;
+ ovs_rwlock_unlock(&pattern_rwlock);
+
+ if (print_syslog_target_deprecation) {
+ VLOG_WARN("--syslog-target flag is deprecated, use "
+ "--syslog-method instead");
+ }
+ }