path: root/src/Makefile.am
diff options
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-09-09 03:36:48 +0700
committerlaforge <laforge@osmocom.org>2020-10-19 15:02:00 +0000
commite7bf4354b9914aa41bd5b7e1fa95095bb77ba4c4 (patch)
treec2248ec5ef6cf970f50176e8327f974c843ff03b /src/Makefile.am
parent7e65791b665477a654b2c905e9b31b5832a814fc (diff)
logging: introduce 'systemd-journal' target
This change implements 'systemd-journal' logging target, that is similar to the existing 'syslog' target. The key difference is that 'systemd-journal' allows us to offload rendering of the meta information, such as location (file name, line number), subsystem, and logging level, to systemd. Moreover, we can attach arbitrary, user-specific fields [1] to the logging messages, so they can be used for advanced log filtering (e.g. by IMSI/TMSI/TLLI): $ journalctl OSMO_SUBSYS=DMSC -f Since we don't want to make libsystemd a required dependency, this feature is optional, and needs to be enabled at build-time: $ ./configure --enable-systemd-logging The new logging target can be configured in the same way as any other one - via the VTY interface, or using the configuration file: log systemd-journal [raw] logging level set-all notice logging filter all 1 Two logging handlers are available: generic and raw. The first one behaves similarly to both 'syslog' and 'stderr', i.e. all the meta information is rendered by libosmocore itself, and then passed to systemd together with the logging message. The later is more like the 'gsmtap' target, so all available meta information is handed over to systemd in form of fields [1]: - CODE_FILE / CODE_LINE - location info, - PRIORITY - syslog-compatible logging level, - OSMO_SUBSYS - Osmocom-specific sub-system (e.g. DMSC), - OSMO_SUBSYS_HEX - same as OSMO_SUBSYS, but encoded in hex, - MESSAGE - the logging message itself, and then can be rendered in any supported format (e.g. JSON). More details about the API can be found in [2]. [1] https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html [2] https://www.freedesktop.org/software/systemd/man/sd-journal.html Change-Id: I609f5cf438e6ad9038d8fc95f00add6aac29fb23
Diffstat (limited to 'src/Makefile.am')
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 891b4a6f..b2c9204f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,5 +71,10 @@ if ENABLE_SERIAL
libosmocore_la_SOURCES += serial.c
+libosmocore_la_SOURCES += logging_systemd.c
+libosmocore_la_LIBADD += $(SYSTEMD_LIBS)
crc%gen.c: crcXXgen.c.tpl
$(AM_V_GEN)sed -e's/XX/$*/g' $< > $@