summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-07-26 16:59:55 +0200
committerLennart Poettering <lennart@poettering.net>2013-07-26 16:59:55 +0200
commita65615ca5d78be0dcd7d9c9b4a663fa75f758606 (patch)
treef131c490f08d7c4e28addeb0fcfbf85701db4005
parentsystemctl: move "dump" command from systemctl to systemd-analyze (diff)
downloadsystemd-a65615ca5d78be0dcd7d9c9b4a663fa75f758606.tar.xz
systemd-a65615ca5d78be0dcd7d9c9b4a663fa75f758606.zip
systemctl: move set-log-level to systemd-analyze
"systemctl set-log-level" is a command for analysis and tracing hence "systemd-analyze" should be the better home for it, thus allowing us to make the overly large "systemctl" a bit smaller.
-rw-r--r--TODO6
-rw-r--r--man/systemctl.xml13
-rw-r--r--man/systemd-analyze.xml20
-rw-r--r--src/analyze/systemd-analyze.c56
-rw-r--r--src/systemctl/systemctl.c49
5 files changed, 77 insertions, 67 deletions
diff --git a/TODO b/TODO
index 5294b74d30..35ce46ff40 100644
--- a/TODO
+++ b/TODO
@@ -51,6 +51,8 @@ CGroup Rework Completion:
Features:
+* remove systemctl load-unit
+
* journalctl: instead --after-cursor= maybe have a --cursor=XYZ+1 syntax?
* given that logind/machined now let PID 1 do all nasty work we can
@@ -88,8 +90,6 @@ Features:
* load .d/*.conf dropins for device units
-* move systemctl set-log-level to systemd-analyze?
-
* add a fixed dbus path for "my own unit", "my own session", ... to PID1, logind, ...
* service_coldplug() appears to reinstall the wrong stop timeout watch?
@@ -123,8 +123,6 @@ Features:
* something pulls in pcre as so dep into our daemons such as hostnamed.
-* cgroup-agent: downgrade error messages
-
* document systemd-journal-flush.service properly
* change systemd-journal-flush into a service that stays around during
diff --git a/man/systemctl.xml b/man/systemctl.xml
index 06c8c18465..45955da179 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -539,19 +539,6 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
</listitem>
</varlistentry>
- <varlistentry>
- <term><command>set-log-level <replaceable>LEVEL</replaceable></command></term>
-
- <listitem>
- <para>Change current log level of the
- <command>systemd</command> daemon to
- <replaceable>LEVEL</replaceable> (accepts the same values
- as <option>--log-level=</option> described in
- <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>).
- </para>
- </listitem>
- </varlistentry>
-
<varlistentry>
<term><command>start <replaceable>NAME</replaceable>...</command></term>
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index 905b44b6d9..a8adf87713 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -81,20 +81,28 @@
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain">dot</arg>
<arg choice="opt" rep="repeat"><replaceable>PATTERN</replaceable></arg>
+ <arg choice="opt">&gt; file.dot</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-analyze</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain">dump</arg>
</cmdsynopsis>
+ <cmdsynopsis>
+ <command>systemd-analyze</command>
+ <arg choice="opt" rep="repeat">OPTIONS</arg>
+ <arg choice="plain">set-log-level</arg>
+ <arg choice="opt"><replaceable>LEVEL</replaceable></arg>
+ </cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><command>systemd-analyze</command> may be used
- to determine system boot-up performance of the current
- boot.</para>
+ to determine system boot-up performance statistics and
+ retrieve other state and tracing information from the
+ system and service manager.</para>
<para><command>systemd-analyze time</command>
prints the time spent in the kernel before
@@ -154,6 +162,14 @@
change without notice and should not be parsed by
applications.</para>
+ <para><command>systemd-analyze set-log-level
+ <replaceable>LEVEL</replaceable></command> changes the
+ current log level of the <command>systemd</command>
+ daemon to <replaceable>LEVEL</replaceable> (accepts
+ the same values as <option>--log-level=</option>
+ described in
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>).</para>
+
<para>If no command is passed, <command>systemd-analyze
time</command> is implied.</para>
diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
index 2748b3afc9..27d063c548 100644
--- a/src/analyze/systemd-analyze.c
+++ b/src/analyze/systemd-analyze.c
@@ -1184,6 +1184,11 @@ static int dump(DBusConnection *bus, char **args) {
dbus_error_init(&error);
+ if (!strv_isempty(args)) {
+ log_error("Too many arguments.");
+ return -E2BIG;
+ }
+
pager_open_if_enabled();
r = bus_method_call_with_reply(
@@ -1210,6 +1215,54 @@ static int dump(DBusConnection *bus, char **args) {
return 0;
}
+static int set_log_level(DBusConnection *bus, char **args) {
+ _cleanup_dbus_error_free_ DBusError error;
+ _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL;
+ DBusMessageIter iter, sub;
+ const char* property = "LogLevel";
+ const char* interface = "org.freedesktop.systemd1.Manager";
+ const char* value;
+
+ assert(bus);
+ assert(args);
+
+ if (strv_length(args) != 1) {
+ log_error("This command expects one argument only.");
+ return -E2BIG;
+ }
+
+ value = args[0];
+ dbus_error_init(&error);
+
+ m = dbus_message_new_method_call("org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.DBus.Properties",
+ "Set");
+ if (!m)
+ return log_oom();
+
+ dbus_message_iter_init_append(m, &iter);
+
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface) ||
+ !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &property) ||
+ !dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, "s", &sub))
+ return log_oom();
+
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &value))
+ return log_oom();
+
+ if (!dbus_message_iter_close_container(&iter, &sub))
+ return log_oom();
+
+ reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+ if (!reply) {
+ log_error("Failed to issue method call: %s", bus_error_message(&error));
+ return -EIO;
+ }
+
+ return 0;
+}
+
static void analyze_help(void) {
pager_open_if_enabled();
@@ -1236,6 +1289,7 @@ static void analyze_help(void) {
" critical-chain Print a tree of the time critical chain of units\n"
" plot Output SVG graphic showing service initialization\n"
" dot Output dependency graph in dot(1) format\n"
+ " set-log-level LEVEL Set logging threshold for systemd\n"
" dump Output state serialization of service manager\n",
program_invocation_short_name);
@@ -1368,6 +1422,8 @@ int main(int argc, char *argv[]) {
r = dot(bus, argv+optind+1);
else if (streq(argv[optind], "dump"))
r = dump(bus, argv+optind+1);
+ else if (streq(argv[optind], "set-log-level"))
+ r = set_log_level(bus, argv+optind+1);
else
log_error("Unknown operation '%s'.", argv[optind]);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 4e33a4182f..08981a8002 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4527,51 +4527,6 @@ finish:
return r;
}
-static int set_log_level(DBusConnection *bus, char **args) {
- _cleanup_dbus_error_free_ DBusError error;
- _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL;
- DBusMessageIter iter, sub;
- const char* property = "LogLevel";
- const char* interface = "org.freedesktop.systemd1.Manager";
- const char* value;
-
- assert(bus);
- assert(args);
-
- value = args[1];
- dbus_error_init(&error);
-
- m = dbus_message_new_method_call("org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.DBus.Properties",
- "Set");
- if (!m)
- return log_oom();
-
- dbus_message_iter_init_append(m, &iter);
-
- if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface) ||
- !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &property) ||
- !dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, "s", &sub))
- return log_oom();
-
- if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &value)) {
- dbus_message_iter_abandon_container(&iter, &sub);
- return log_oom();
- }
-
- if (!dbus_message_iter_close_container(&iter, &sub))
- return log_oom();
-
- reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
- if (!reply) {
- log_error("Failed to issue method call: %s", bus_error_message(&error));
- return -EIO;
- }
-
- return 0;
-}
-
static int unit_is_enabled(DBusConnection *bus, char **args) {
_cleanup_dbus_error_free_ DBusError error;
int r;
@@ -4759,8 +4714,7 @@ static int systemctl_help(void) {
"Environment Commands:\n"
" show-environment Dump environment\n"
" set-environment [NAME=VALUE...] Set one or more environment variables\n"
- " unset-environment [NAME...] Unset one or more environment variables\n"
- " set-log-level LEVEL Set logging threshold for systemd\n\n"
+ " unset-environment [NAME...] Unset one or more environment variables\n\n"
"Manager Lifecycle Commands:\n"
" daemon-reload Reload systemd manager configuration\n"
" daemon-reexec Reexecute systemd manager\n\n"
@@ -5824,7 +5778,6 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
{ "list-dependencies", LESS, 2, list_dependencies },
{ "set-default", EQUAL, 2, enable_unit },
{ "get-default", LESS, 1, get_default },
- { "set-log-level", EQUAL, 2, set_log_level },
{ "set-property", MORE, 3, set_property },
};