You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by gdamjan <gi...@git.apache.org> on 2016/10/03 16:42:31 UTC

[GitHub] couchdb-couch-log pull request #16: a systemd-journald compatible log output...

GitHub user gdamjan opened a pull request:

    https://github.com/apache/couchdb-couch-log/pull/16

    a systemd-journald compatible log output on stderr

    based on the stderr logger but changed:
    - doesn't output the timestamp, the journal already has a timestamp
    - output the log level as <num> where num is defined as in `sd-daemon(3)`
    
    https://www.freedesktop.org/software/systemd/man/sd-daemon.html

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gdamjan/couchdb-couch-log master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch-log/pull/16.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16
    
----
commit 406dccdc296e5638d7a52818c27180cfe168b0fd
Author: Damjan Georgievski <gd...@gmail.com>
Date:   2016-10-03T16:17:59Z

    a systemd-journald compatible log output on stderr
    
    based on the stderr logger but changed:
    - doesn't output the timestamp, the journal already has a timestamp
    - output the log level as <num> where num is defined as in `sd-daemon(3)`
    
    https://www.freedesktop.org/software/systemd/man/sd-daemon.html

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log issue #16: a systemd-journald compatible log output on std...

Posted by gdamjan <gi...@git.apache.org>.
Github user gdamjan commented on the issue:

    https://github.com/apache/couchdb-couch-log/pull/16
  
    @kxepal I guess so, let me see what the systemd community thinks too (maybe there's previous precedent).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log pull request #16: a systemd-journald compatible log output...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-log/pull/16#discussion_r81591731
  
    --- Diff: src/couch_log_writer_journal.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_journal).
    +-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.
    +
    +write(Entry, St) ->
    +    #log_entry{
    +        level = Level,
    +        pid = Pid,
    +        msg = Msg,
    +        msg_id = MsgId
    +    } = Entry,
    +    Fmt = "<~B>~s ~p ~s ",
    +    Args = [
    +        level_to_integer(Level),
    +        node(),
    --- End diff --
    
    Wouldn't [St#st.hostname](https://github.com/apache/couchdb-couch-log/blob/master/src/couch_log_writer_syslog.erl#L85-L86) and friends be more informative here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log issue #16: a systemd-journald compatible log output on std...

Posted by gdamjan <gi...@git.apache.org>.
Github user gdamjan commented on the issue:

    https://github.com/apache/couchdb-couch-log/pull/16
  
    this setup works fine when configured in in `local.ini`:
    ```
    [log]
    writer = journal
    ```
    
    but perhaps it would be better if the writer can be forced from the systemd service file (via a environment variable or command line option).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-log issue #16: a systemd-journald compatible log output on std...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the issue:

    https://github.com/apache/couchdb-couch-log/pull/16
  
    LGFM, but I'm not systemd user.
    
    @gdamjan may be name it journald to direct match with the service name without leaving a room for confusion?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---