log: Initialise timestamp for relative log time also if we use a log file
...not just for debug messages. Otherwise, timestamps in the log file are consistent but the starting point is not zero. Do this right away as we enter main(), so that the resulting timestamps are as closely as possible relative to when we start. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
327d9d482f
commit
e5c37ba0f4
3 changed files with 4 additions and 3 deletions
4
log.c
4
log.c
|
@ -40,7 +40,7 @@ static size_t log_written; /* Currently used bytes in log file */
|
||||||
static size_t log_cut_size; /* Bytes to cut at start on rotation */
|
static size_t log_cut_size; /* Bytes to cut at start on rotation */
|
||||||
static char log_header[BUFSIZ]; /* File header, written back on cuts */
|
static char log_header[BUFSIZ]; /* File header, written back on cuts */
|
||||||
|
|
||||||
static struct timespec log_start; /* Start timestamp */
|
struct timespec log_start; /* Start timestamp */
|
||||||
|
|
||||||
int log_trace; /* --trace mode enabled */
|
int log_trace; /* --trace mode enabled */
|
||||||
bool log_conf_parsed; /* Logging options already parsed */
|
bool log_conf_parsed; /* Logging options already parsed */
|
||||||
|
@ -154,8 +154,6 @@ void __openlog(const char *ident, int option, int facility)
|
||||||
{
|
{
|
||||||
(void)option;
|
(void)option;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &log_start);
|
|
||||||
|
|
||||||
if (log_sock < 0) {
|
if (log_sock < 0) {
|
||||||
struct sockaddr_un a = { .sun_family = AF_UNIX, };
|
struct sockaddr_un a = { .sun_family = AF_UNIX, };
|
||||||
|
|
||||||
|
|
1
log.h
1
log.h
|
@ -44,6 +44,7 @@ void logmsg_perror(int pri, const char *format, ...)
|
||||||
extern int log_trace;
|
extern int log_trace;
|
||||||
extern bool log_conf_parsed;
|
extern bool log_conf_parsed;
|
||||||
extern bool log_runtime;
|
extern bool log_runtime;
|
||||||
|
extern struct timespec log_start;
|
||||||
|
|
||||||
void trace_init(int enable);
|
void trace_init(int enable);
|
||||||
#define trace(...) \
|
#define trace(...) \
|
||||||
|
|
2
passt.c
2
passt.c
|
@ -207,6 +207,8 @@ int main(int argc, char **argv)
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_REALTIME, &log_start);
|
||||||
|
|
||||||
arch_avx2_exec(argv);
|
arch_avx2_exec(argv);
|
||||||
|
|
||||||
isolate_initial();
|
isolate_initial();
|
||||||
|
|
Loading…
Reference in a new issue