%% Licensed to the Apache Software Foundation (ASF) under one %% or more contributor license agreements. See the NOTICE file %% distributed with this work for additional information %% regarding copyright ownership. The ASF licenses this file %% to you under the Apache License, Version 2.0 (the %% "License"); you may not use this file except in compliance %% with the License. You may obtain a copy of the License at %% %% http://www.apache.org/licenses/LICENSE-2.0 %% %% Unless required by applicable law or agreed to in writing, %% software distributed under the License is distributed on an %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY %% KIND, either express or implied. See the License for the %% specific language governing permissions and limitations %% under the License. %% %% @doc %% Formatter wrapper for systemd's journal level information. %% %% Journald uses log-level format similar to Linux's `printk' logging function. %% This simply adds special prefix to the message formatted by the formatter %% specified via `parent' option. %% %% == Automatic registration == %% %% This formatter will be automatically registered for all handlers that use %% `logger_std_h' with `type' set to one of `standard_io' or `standard_error' if %% the respective FDs point to journal that is pointed by `JOURNAL_STREAM' which %% is autometically set by systemd if one of the options `StandardOutput' or %% `StandardError' is set to `journal'. So if you are using default logger %% handler then all you need to do is to set %% %% ``` %% StandardOutput=journal %% ''' %% %% In your `systemd.service(8)' file, and this library will handle the rest. %% %% It is important that this formatter will still work poorly with multiline %% logs, if you are using such, then check out {@link systemd_journal_h. %% `systemd_journal_h'} handler (which SHOULD NOT be used with this %% formatter). %% %% To disable this behaviour set `auto_formatter' option for `systemd' to %% `false'. %% %% == Example == %% %% ``` %% logger:add_handler(journal_stdout, %% logger_std_h, %% #{formatter => {systemd_kmsg_formatter, #{}}). %% ''' %% %% == Options == %% %%