You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/01/04 20:16:31 UTC

[GitHub] [couchdb] gdamjan commented on a change in pull request #1912: a systemd-journald compatible log output on stderr

gdamjan commented on a change in pull request #1912: a systemd-journald compatible log output on stderr
URL: https://github.com/apache/couchdb/pull/1912#discussion_r363053138
 
 

 ##########
 File path: src/couch_log/src/couch_log_writer_journald.erl
 ##########
 @@ -0,0 +1,69 @@
+% Licensed 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.
+
+-module(couch_log_writer_journald).
+-behaviour(couch_log_writer).
+
+
+-export([
+    init/0,
+    terminate/2,
+    write/2
+]).
+
+
+-include("couch_log.hrl").
+
+
+init() ->
+    {ok, nil}.
+
+
+terminate(_, _St) ->
+    ok.
+
+
+% log level mapping from sd-daemon(3)
+% https://www.freedesktop.org/software/systemd/man/sd-daemon.html
+-spec level_to_integer(atom() | string() | integer()) -> integer().
+level_to_integer(debug)                 -> 7;
+level_to_integer(info)                  -> 6;
+level_to_integer(notice)                -> 5;
+level_to_integer(warning)               -> 4;
+level_to_integer(warn)                  -> 4;
+level_to_integer(error)                 -> 3;
+level_to_integer(err)                   -> 3;
+level_to_integer(critical)              -> 2;
+level_to_integer(crit)                  -> 2;
+level_to_integer(alert)                 -> 1;
+level_to_integer(emergency)             -> 0;
+level_to_integer(emerg)                 -> 0;
+level_to_integer(none)                  -> 6.
 
 Review comment:
   thanks, I'll have to double check that, it's been awhile since I wrote this patch.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services