-
Notifications
You must be signed in to change notification settings - Fork 98
log: Add configure-time option to use systemd journal instead of syslog #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
configure.ac
Outdated
|
|
||
| if test "x$enable_systemd_journal" = "xyes" ; then | ||
| AX_SAVE_FLAGS | ||
| AC_SEARCH_LIBS([sd_journal_send], [systemd-journal],,[AC_MSG_ERROR([cannot find sd_journal_send() function])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend using PKG_CHECK_MODULES (because it sets correctly not only the LIBS but also the CFLAGS.
Also (without deep knowledge about history) this code seems to work for CentOS 7, but Fedora 28+ seems not to have systemd-journal library at all and instead it's using libsystemd (https://www.freedesktop.org/software/systemd/man/sd-journal.html)
configure.ac
Outdated
| if test "x$have_systemd" = "xyes" ; then | ||
| AC_DEFINE_UNQUOTED(USE_JOURNAL, 1, [Use systemd journal logging]) | ||
| USE_JOURNAL="yes" | ||
| echo "CC: found systemd & journal requested" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug print should go or be replaced by something without CC: prefix :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err yes. That should never have been left in. TBH I only pushed it to move a copy to my Fedora system for testing!
examples/Makefile.am
Outdated
| mapnotify_SOURCES = mapnotify.c $(top_builddir)/include/qb/qbmap.h | ||
| mapnotify_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include | ||
| mapnotify_LDADD = $(top_builddir)/lib/libqb.la | ||
| mapnotify_LDADD = $(top_builddir)/lib/libqb.la $(SYSTEMD_LIBS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this adding $(SYSTEMD_LIBS) everywhere is good idea (and if it really is, then libqb.pc must be changed).
What about changing lib/Makefile.am and add $(SYSTEMD_CFLAGS) and $(SYSTEMD_LIBS) to libqb_la_CFLAGS and libqb_la_LIBADD? Then libqb.la gets dependency on systemd (when needed) and apps using libqb will need no change? (please correct me if I'm wrong, I'm not libtool magic master).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly. I'm struggling with auto-stuff too, It will definitely need to go in the pkgfile somehow
wferi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find making the systemd journal a syslog replacement too heavy handed, because it disallows using the same binary under different init systems. And init system choice is a system configuration question in Debian at least.
configure.ac
Outdated
| fi | ||
|
|
||
| # Add to LIBS for pkgconfig file | ||
| LIBS+="$SYSTEMD_LIBS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to add @SYSTEMD_LIBS@ to Libs.private instead. Changing LIBS adds the library to every link command.
configure.ac
Outdated
| [ SOCKETDIR="$localstatedir/run" ]) | ||
|
|
||
| AC_ARG_ENABLE([systemd-journal], | ||
| [AS_HELP_STRING([--with-systemd-journal=DIR],[Use systemd journal instead of syslog])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The =DIR part seems superfluous here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, copy/paste laziness.
|
Thanks for that - it never occurred to me that both might be available. Not being a Debian user. Do you have any suggestions on how it might be made switchable? Having said that, it would need the systemd libs to be dragged in even on a non-systemd installation if it was made run-time switchable - which I suspect would be less than popular given some of the opinions on systemd! In such circumstances it might just be easier to build for syslog and leave it at that. It will still work on systemd systems but you wouldn't get the logging metadata of course? I'm interested in opinions here. |
|
Maybe overkill, but it would be possible to add build-time support for run-time selection. I.e. a configure option for system log that could be set to syslog, systemd, or both, and if both, that would enable a run-time option to select syslog or systemd. Distros could pick one option or even offer multiple variants to get around the dependency issue. (I hadn't thought about that before, but a distro like Debian could even offer a pacemaker-systemd package that depended on libqb-systemd, with systemd support enabled in both, and non-systemd packages without that support.) |
|
Cleanest would be to make it an API choice in addition to file and syslog. The obvious drawback is that all applications would have to parse and act on an additional config option, so you get |
|
Thanks. So if you're OK with libqb always linking with systemd-journal (depending on the configure flag of course) then I'll add a flag to qb_log_ctl that allows the application to choose syslog or journald. The default will be syslog. |
|
That would be perfectly fine from the library packager's point of view (let's hope I don't forget to bump the symbol version info for this ABI extension). Yeah, it's a little awkward to pull in a new library for a single function, but requiring applications to pass in the address of |
|
@wferi Current code is already using unified libsystemd. IMHO we don't need to try to keep backwards compatibility with libsystemd-journal (I found it in Debian wheezy (already unsupported), jessie (only for some architectures), and in RHEL library still exists but only to keep "compatibility" and main library is libststemd (since 7.2 which is already EOL)). |
|
@jfriesse Even better. I remembered the original patch using the legacy library, and Chrissie mentioned it again in her latest comment, so I decided to mention it again. I'm all for forgetting about the old name if it's acceptable for you. |
|
it was just a slip of the keyboard really, partly also cause by the fact that my desktop is running RHEL7 ;) |
|
I've force committed an updated patch that should have tidied everything up. see what you think |
|
All those conditionals in the |
| /* | ||
| * You can still use syslog and journal in a normal application, | ||
| * but the syslog_override code doesn't work when -lsystemd is present | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this some load order problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried moving the link order around with no luck. TBH I don't care enough to spend time on it as it's only a test program. If you do, then I'm happy to take patches ;-)
|
because that's what seemed to be the consensus in earlier discussions? |
|
But also, I don't see the point in having both available at the same time. If systemd is installed then sending to syslog AND the journal is sending the message to the same place twice, it's just that one has the metadata and one doesn't. |
|
I'm sorry for the confusion, it's entirely my fault: I overestimated the scope of |
|
No problem. I don't have a strong opinion on which way to add this in. My very first thought was to do as you suggest and add a whole new target type but it seemed overkill. |
|
I like sharing the slot. I see the systemd journal more as an enhanced syslog variant than an independent mechanism, most obviously because it takes over the logger command and syslog() function, but also because it serves the same logical function (aggregating log output from daemons). It has a separate API if someone wants to use it, but that's on top of the traditional syslog API (i.e. more like an extension). |
|
I'm also for qb_ctl mechanism instead of new target type. AFAIK when systemd is used as init system then journald is used and it owns /dev/log without any way to disable such behavior. Then syslog = journald. Contrary on systems without systemd, journald is not used and only syslog make sense. So it's basically on/off switch, not binary none, one or other or both. |
| } else { | ||
| rc = -EINVAL; | ||
| } | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code silently ignores this operation if USE_JOURNAL is not defined. Wouldn't it be better to return some error instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. commit added (with test)
|
The above arguments for disallowing parallel use hinge on |
|
@wferi It's good to know that it's possible to disable journald /dev/log. I was trying to stop this behavior quite a long time ago (RHEL 7.0), because journald was throwing messages (what is also probably fixed) used by cts. So I wanted to replace it by syslog, but without success. |
|
@jfriesse I recently had the same issue with journald rate-limiting messages from CTS runs; this was my fix: By default it rate-limits after 10,000 messages in 30 seconds from a single package. That changes it to 10,000 messages in 2 seconds. (It's possible to disable it altogether, but I read that that causes performance issues.) |
systemd journal can be configured as a logging option at ./configure time (--enable-systemd-journal). If libqb is buit with this then the syslog target can be switched to sending to the journal using qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_USE_JOURNAL, 1);
|
Thanks for all the helpful comments on this. |
As most of this patch is in the config system I'm hoping some nice person will fix it up for me - it does (seem to ) work, but I suspect it's not optimal.
The actual code is trivial.