[systemd-devel] [Patch 0/5] support for logging the unit of user session units

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Thu Jan 17 22:08:25 PST 2013


On Thu, Jan 17, 2013 at 06:55:04PM +0100, Mirco Tischler wrote:
> Hi
> 
> The following series of patches implements support for logging user
> session units to the journal. Messages by the unit itself are marked with
> _SYSTEMD_USER_UNIT and messages regarding the unit from the systemd
> instance are marked with USER_UNIT.
Hi,
I had a look at the your patches (without actually running them :).
I started with a few cleanups, I'll post them as replies to this letter.
Then I had a better look at the logic of USER_UNIT and I have a few
questions.

-#define log_full_unit(level, unit, ...) log_meta_object(level,   __FILE__, __LINE__, __func__, "UNIT=", unit, __VA_ARGS__)
+#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
+#define log_struct_unit(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)

Are all those calls to getpid() efficient? Is the result cached or does
each one generate a system call?

+        if (!endswith(unit, ".service") &&
+            !endswith(unit, ".socket") &&
+            !endswith(unit, ".mount") &&
+            !endswith(unit, ".swap"))
+                return 0;

+        if (!endswith(unit, ".service") &&
+            !endswith(unit, ".socket"))

Do those conditions make sense? Aren't the messages logged for 
all types of units (at least under debug or error conditions)
by systemd itself?

Zbyszek


More information about the systemd-devel mailing list