mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 14:55:18 +00:00
12
lib/vlog.c
12
lib/vlog.c
@@ -28,6 +28,7 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "async-append.h"
|
||||||
#include "coverage.h"
|
#include "coverage.h"
|
||||||
#include "dirs.h"
|
#include "dirs.h"
|
||||||
#include "dynamic-string.h"
|
#include "dynamic-string.h"
|
||||||
@@ -95,6 +96,7 @@ static struct facility facilities[VLF_N_FACILITIES] = {
|
|||||||
/* VLF_FILE configuration. */
|
/* VLF_FILE configuration. */
|
||||||
static char *log_file_name;
|
static char *log_file_name;
|
||||||
static int log_fd = -1;
|
static int log_fd = -1;
|
||||||
|
static struct async_append *log_writer;
|
||||||
|
|
||||||
/* vlog initialized? */
|
/* vlog initialized? */
|
||||||
static bool vlog_inited;
|
static bool vlog_inited;
|
||||||
@@ -281,6 +283,10 @@ vlog_set_log_file(const char *file_name)
|
|||||||
/* Close old log file. */
|
/* Close old log file. */
|
||||||
if (log_fd >= 0) {
|
if (log_fd >= 0) {
|
||||||
VLOG_INFO("closing log file");
|
VLOG_INFO("closing log file");
|
||||||
|
|
||||||
|
async_append_destroy(log_writer);
|
||||||
|
log_writer = NULL;
|
||||||
|
|
||||||
close(log_fd);
|
close(log_fd);
|
||||||
log_fd = -1;
|
log_fd = -1;
|
||||||
}
|
}
|
||||||
@@ -307,6 +313,7 @@ vlog_set_log_file(const char *file_name)
|
|||||||
log_file_name, ovs_strerror(errno));
|
log_file_name, ovs_strerror(errno));
|
||||||
error = errno;
|
error = errno;
|
||||||
} else {
|
} else {
|
||||||
|
log_writer = async_append_create(log_fd);
|
||||||
VLOG_INFO("opened log file %s", log_file_name);
|
VLOG_INFO("opened log file %s", log_file_name);
|
||||||
error = 0;
|
error = 0;
|
||||||
}
|
}
|
||||||
@@ -786,7 +793,10 @@ vlog_valist(const struct vlog_module *module, enum vlog_level level,
|
|||||||
format_log_message(module, level, VLF_FILE, msg_num,
|
format_log_message(module, level, VLF_FILE, msg_num,
|
||||||
message, args, &s);
|
message, args, &s);
|
||||||
ds_put_char(&s, '\n');
|
ds_put_char(&s, '\n');
|
||||||
ignore(write(log_fd, s.string, s.length));
|
async_append_write(log_writer, s.string, s.length);
|
||||||
|
if (level == VLL_EMER) {
|
||||||
|
async_append_flush(log_writer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ds_destroy(&s);
|
ds_destroy(&s);
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "async-append.h"
|
||||||
#include "bfd.h"
|
#include "bfd.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "bond.h"
|
#include "bond.h"
|
||||||
@@ -2444,6 +2445,8 @@ bridge_run(void)
|
|||||||
* process that forked us to exit successfully. */
|
* process that forked us to exit successfully. */
|
||||||
daemonize_complete();
|
daemonize_complete();
|
||||||
|
|
||||||
|
async_append_enable();
|
||||||
|
|
||||||
VLOG_INFO_ONCE("%s (Open vSwitch) %s", program_name, VERSION);
|
VLOG_INFO_ONCE("%s (Open vSwitch) %s", program_name, VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user