mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
virsh: Add timestamps to events
A new --timestamp option for event virsh command can be used to print timestamp of each event. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
7cbb7f059a
commit
aa7735e9d1
@ -12137,6 +12137,7 @@ struct virshDomEventData {
|
|||||||
vshControl *ctl;
|
vshControl *ctl;
|
||||||
bool loop;
|
bool loop;
|
||||||
int *count;
|
int *count;
|
||||||
|
bool timestamp;
|
||||||
vshEventCallback *cb;
|
vshEventCallback *cb;
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
@ -12164,7 +12165,16 @@ virshEventPrint(virshDomEventData *data,
|
|||||||
if (!data->loop && *data->count)
|
if (!data->loop && *data->count)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (data->timestamp) {
|
||||||
|
char timestamp[VIR_TIME_STRING_BUFLEN];
|
||||||
|
|
||||||
|
if (virTimeStringNowRaw(timestamp) < 0)
|
||||||
|
timestamp[0] = '\0';
|
||||||
|
|
||||||
|
vshPrint(data->ctl, "%s: %s", timestamp, msg);
|
||||||
|
} else {
|
||||||
vshPrint(data->ctl, "%s", msg);
|
vshPrint(data->ctl, "%s", msg);
|
||||||
|
}
|
||||||
|
|
||||||
(*data->count)++;
|
(*data->count)++;
|
||||||
if (!data->loop)
|
if (!data->loop)
|
||||||
@ -12543,6 +12553,10 @@ static const vshCmdOptDef opts_event[] = {
|
|||||||
.type = VSH_OT_BOOL,
|
.type = VSH_OT_BOOL,
|
||||||
.help = N_("list valid event types")
|
.help = N_("list valid event types")
|
||||||
},
|
},
|
||||||
|
{.name = "timestamp",
|
||||||
|
.type = VSH_OT_BOOL,
|
||||||
|
.help = N_("show timestamp for each printed event")
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -12558,6 +12572,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int event = -1;
|
int event = -1;
|
||||||
bool all = vshCommandOptBool(cmd, "all");
|
bool all = vshCommandOptBool(cmd, "all");
|
||||||
bool loop = vshCommandOptBool(cmd, "loop");
|
bool loop = vshCommandOptBool(cmd, "loop");
|
||||||
|
bool timestamp = vshCommandOptBool(cmd, "timestamp");
|
||||||
int count = 0;
|
int count = 0;
|
||||||
virshControlPtr priv = ctl->privData;
|
virshControlPtr priv = ctl->privData;
|
||||||
|
|
||||||
@ -12590,6 +12605,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
data[i].ctl = ctl;
|
data[i].ctl = ctl;
|
||||||
data[i].loop = loop;
|
data[i].loop = loop;
|
||||||
data[i].count = &count;
|
data[i].count = &count;
|
||||||
|
data[i].timestamp = timestamp;
|
||||||
data[i].cb = &vshEventCallbacks[i];
|
data[i].cb = &vshEventCallbacks[i];
|
||||||
data[i].id = -1;
|
data[i].id = -1;
|
||||||
}
|
}
|
||||||
@ -12599,6 +12615,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
data[0].ctl = ctl;
|
data[0].ctl = ctl;
|
||||||
data[0].loop = vshCommandOptBool(cmd, "loop");
|
data[0].loop = vshCommandOptBool(cmd, "loop");
|
||||||
data[0].count = &count;
|
data[0].count = &count;
|
||||||
|
data[0].timestamp = timestamp;
|
||||||
data[0].cb = &vshEventCallbacks[event];
|
data[0].cb = &vshEventCallbacks[event];
|
||||||
data[0].id = -1;
|
data[0].id = -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user