hauleth / erlang-systemd

systemd utilities for Erlang applications
Apache License 2.0
174 stars 19 forks source link

Automatic registration of journal handlers on systemd-enabled OSes? #9

Closed hauleth closed 4 years ago

hauleth commented 4 years ago

It could be done within application:

case systemd:booted() of
  true -> logger:add_handlers(systemd);
  false -> ok
end.

However I am not sure if such magic would be expected from such library. On the other hand we already automagically handle watchdog events and connecting to NOTIFY_SOCKET, so maybe something like that would be considered ok as well? The only problem I see is that without deregistering default logger it would end with duplicated log entries in journal, and removing default handler is something I would prefer to avoid.

hauleth commented 4 years ago

Next version (0.5) will automatically update the formatter to use kmsg-like level prefixes if detected logger_std_h pointed to the journal stream. The question about automatic registration of systemd_journal_h however remains. The problem I see is that it can cause duplicated entries to be present in the journal, which I would avoid. So for now closing and maybe it will be reopened in future if needed.