Skip to content

Commit

Permalink
Add pid and ident to syslog messages. Also allow facility to be toggl…
Browse files Browse the repository at this point in the history
…ed between user and local0.
  • Loading branch information
Martin Cox committed Mar 2, 2022
1 parent c2ce4ea commit 50dbd47
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions priv/riak.schema
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
%% @doc Determines if messages should emit to syslog.
{mapping, "syslogger.enabled", "kernel.logger", [
{default, off},
{datatype, flag}
{datatype, {flag, on, off}}
]}.

%% @doc The severity level of the syslog log, default is 'notice'.
Expand All @@ -46,6 +46,12 @@
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.

%% @doc The syslog facility to use, default is 'user'.
{mapping, "syslogger.facility", "kernel.logger", [
{default, user},
{datatype, {enum, [user, local0]}}
]}.

%% @doc Format string for the messages emitted to syslog. The string is passed into
%% the handler as a logger_formatter template, the format is a list containing strings
%% and atoms. The atoms denote the keys for retrieving metadata from the logger events.
Expand All @@ -55,6 +61,14 @@
{datatype, string}
]}.

%% @doc Default opts that need setting for the syslogger application to ensure that
%% the PID is printed with log messages, along with the correct process identifier.
{translation, "syslogger",
fun(_Conf) ->
[{log_opts, [pid]}, {ident, "riak"}]
end
}.

{translation,
"kernel.logger",
fun(Conf) ->
Expand Down Expand Up @@ -89,6 +103,7 @@
case cuttlefish:conf_get("syslogger.enabled", Conf) of
true ->
SyslogLevel = cuttlefish:conf_get("syslogger.level", Conf),
SyslogFacility = cuttlefish:conf_get("syslogger.facility", Conf),
SyslogFormatStr = cuttlefish:conf_get("syslogger.format", Conf),
SyslogFormatTerm =
case erl_scan:string(SyslogFormatStr) of
Expand All @@ -105,7 +120,7 @@
ConfigMap1 = #{level => SyslogLevel,
formatter => {logger_formatter,
#{template => SyslogFormatTerm,
single_line => true}}, facility => user},
single_line => true}}, facility => SyslogFacility},
[{handler, syslog, syslogger, ConfigMap1}];
false ->
[]
Expand Down

0 comments on commit 50dbd47

Please sign in to comment.