[systemd-devel] [PATCH] systemctl: add command set-log-level

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Tue Jun 4 07:47:47 PDT 2013


On Tue, Jun 04, 2013 at 04:44:51PM +0200, Lennart Poettering wrote:
> On Wed, 29.05.13 16:08, Vaclav Pavlin (vpavlin at redhat.com) wrote:
> 
> > From: Václav Pavlín <vpavlin at redhat.com>
> > 
> > Command changes current log level
> > ---
> >  man/systemctl.xml         |  8 ++++++++
> >  src/systemctl/systemctl.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 56 insertions(+)
> > 
> > diff --git a/man/systemctl.xml b/man/systemctl.xml
> > index 9c3a5b0..af72972 100644
> > --- a/man/systemctl.xml
> > +++ b/man/systemctl.xml
> > @@ -1016,6 +1016,14 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
> >        </varlistentry>
> >  
> >        <varlistentry>
> > +        <term><command>set-log-level <replaceable>LEVEL</replaceable></command></term>
> > +
> > +        <listitem>
> > +          <para>Change current log level to LEVEL.</para>
> > +        </listitem>
> > +      </varlistentry>
> > +
> > +      <varlistentry>
> >          <term><command>load <replaceable>NAME</replaceable>...</command></term>
> >  
> >          <listitem>
> > diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
> > index 0955f2c..e6e2f2b 100644
> > --- a/src/systemctl/systemctl.c
> > +++ b/src/systemctl/systemctl.c
> > @@ -4462,6 +4462,53 @@ 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);
> > +
> > +        if (!(m = dbus_message_new_method_call(
> > +                        "org.freedesktop.systemd1",
> > +                        "/org/freedesktop/systemd1",
> > +                        "org.freedesktop.DBus.Properties",
> > +                        "Set")))
> > +                return log_oom();
> 
> 
> For new code we prefer this:
> 
> m = foo();
> if (!m) { ...
I fixed that up before committing.

> 
> rather than this:
> 
> if (!(m = foo())) { ...
> 
> >  static int unit_is_enabled(DBusConnection *bus, char **args) {
> >          _cleanup_dbus_error_free_ DBusError error;
> >          int r;
> > @@ -5705,6 +5752,7 @@ 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     },
> >          };
> 
> Shouldn't this be listed in --help, too?

This too, iirc.

Zbyszek


More information about the systemd-devel mailing list