提交 06b91785 编写于 作者: E Erik Skultety

virt-admin: Wire-up the logging APIs

Finally, now that all APIs have been introduced, wire them up to virt-admin
and introduce daemon-log-outputs and daemon-log-filters commands.
Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 1a38fbaa
......@@ -971,6 +971,114 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
/* --------------------------
* Command daemon-log-filters
* --------------------------
*/
static const vshCmdInfo info_daemon_log_filters[] = {
{.name = "help",
.data = N_("fetch or set the currently defined set of logging filters on "
"daemon")
},
{.name = "desc",
.data = N_("Depending on whether run with or without options, the command "
"fetches or redefines the existing active set of filters on "
"daemon.")
},
{.name = NULL}
};
static const vshCmdOptDef opts_daemon_log_filters[] = {
{.name = "filters",
.type = VSH_OT_STRING,
.help = N_("redefine the existing set of logging filters"),
.flags = VSH_OFLAG_EMPTY_OK
},
{.name = NULL}
};
static bool
cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cmd)
{
int nfilters;
char *filters = NULL;
vshAdmControlPtr priv = ctl->privData;
if (vshCommandOptBool(cmd, "filters")) {
if ((vshCommandOptStringReq(ctl, cmd, "filters",
(const char **) &filters) < 0 ||
virAdmConnectSetLoggingFilters(priv->conn, filters, 0) < 0)) {
vshError(ctl, _("Unable to change daemon logging settings"));
return false;
}
} else {
if ((nfilters = virAdmConnectGetLoggingFilters(priv->conn,
&filters, 0)) < 0) {
vshError(ctl, _("Unable to get daemon logging filters information"));
return false;
}
vshPrintExtra(ctl, " %-15s", _("Logging filters: "));
vshPrint(ctl, "%s\n", filters ? filters : "");
}
return true;
}
/* --------------------------
* Command daemon-log-outputs
* --------------------------
*/
static const vshCmdInfo info_daemon_log_outputs[] = {
{.name = "help",
.data = N_("fetch or set the currently defined set of logging outputs on "
"daemon")
},
{.name = "desc",
.data = N_("Depending on whether run with or without options, the command "
"fetches or redefines the existing active set of outputs on "
"daemon.")
},
{.name = NULL}
};
static const vshCmdOptDef opts_daemon_log_outputs[] = {
{.name = "outputs",
.type = VSH_OT_STRING,
.help = N_("redefine the existing set of logging outputs"),
.flags = VSH_OFLAG_EMPTY_OK
},
{.name = NULL}
};
static bool
cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd)
{
int noutputs;
char *outputs = NULL;
vshAdmControlPtr priv = ctl->privData;
if (vshCommandOptBool(cmd, "outputs")) {
if ((vshCommandOptStringReq(ctl, cmd, "outputs",
(const char **) &outputs) < 0 ||
virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) {
vshError(ctl, _("Unable to change daemon logging settings"));
return false;
}
} else {
if ((noutputs = virAdmConnectGetLoggingOutputs(priv->conn,
&outputs, 0)) < 0) {
vshError(ctl, _("Unable to get daemon logging outputs information"));
return false;
}
vshPrintExtra(ctl, " %-15s", _("Logging outputs: "));
vshPrint(ctl, "%s\n", outputs ? outputs : "");
}
return true;
}
static void *
vshAdmConnectionHandler(vshControl *ctl)
{
......@@ -1341,6 +1449,18 @@ static const vshCmdDef managementCmds[] = {
.info = info_srv_clients_set,
.flags = 0
},
{.name = "daemon-log-filters",
.handler = cmdDaemonLogFilters,
.opts = opts_daemon_log_filters,
.info = info_daemon_log_filters,
.flags = 0
},
{.name = "daemon-log-outputs",
.handler = cmdDaemonLogOutputs,
.opts = opts_daemon_log_outputs,
.info = info_daemon_log_outputs,
.flags = 0
},
{.name = NULL}
};
......
......@@ -155,6 +155,60 @@ change its internal configuration.
Lists all manageable servers contained within the daemon the client is
currently connected to.
=item B<daemon-log-filters> [I<--filters> B<string>]
When run without arguments, this returns the currently defined set of logging
filters. Providing an argument will cause the command to define a new set of
logging filters.
=over 4
=item I<--filters>
Define a new set of logging filters where multiple filters are delimited by
space. Each filter must conform to the form described in detail by
I</etc/libvirt/libvirtd.conf> (section 'Logging filters').
=back
B<Example>
To define a filter which suppresses all e.g. 'virObjectUnref' DEBUG
messages, use the following:
$ virt-admin daemon-log-filters "4:util.object"
(Note the '.' symbol which can be used to more fine-grained filters tailored
to specific modules, in contrast, to affect the whole directory containing
several modules this would become "4:util"):
=item B<daemon-log-outputs> [I<--outputs> B<string>]
When run without arguments, this returns the currently defined set of logging
outputs. Providing an argument will cause the command to define a new set of
logging outputs.
=over 4
=item I<--outputs>
Define a new set of logging outputs where multiple outputs are delimited by
space. Each output must conform to the form described in detail by
I</etc/libvirt/libvirtd.conf> (section 'Logging outputs').
=back
B<Example>
To replace the current setting for logging outputs with one that writes to
a file while logging errors only, the following could be used:
$ virt-admin daemon-log-outputs "4:file:<absolute_path_to_the_file>"
To define multiple outputs at once they need to be delimited by spaces:
$ virt-admin daemon-log-outputs "4:stderr 2:syslog:<msg_ident>"
=back
=head1 SERVER COMMANDS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册