You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/03/17 01:40:33 UTC

[jira] [Commented] (COUCHDB-2970) config:set("log","level",...) fails to change lager backend levels

    [ https://issues.apache.org/jira/browse/COUCHDB-2970?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15198489#comment-15198489 ] 

ASF GitHub Bot commented on COUCHDB-2970:
-----------------------------------------

GitHub user jaydoane opened a pull request:

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

    Get lager event handlers from gen_event

    The existing mechanism for getting lager_event's handlers incorrectly uses the data structure returned by application:get_env, which returns a configuration data structure defined in sys.config. The actual lager_event handler list is obtained directly from gen_event.
    
    COUCHDB-2970

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

    $ git pull https://github.com/cloudant/couchdb-couch-log-lager 2970-lager-handlers-from-gen_event

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

    https://github.com/apache/couchdb-couch-log-lager/pull/2.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 #2
    
----
commit 60d29078f27732cdc4e12a6ad81286b9062f8b61
Author: Jay Doane <ja...@gmail.com>
Date:   2016-03-17T00:37:54Z

    Get lager event handlers from gen_event
    
    The existing mechanism for getting lager_event's handlers incorrectly uses the data structure returned by application:get_env, which returns a configuration data structure defined in sys.config. The actual lager_event handler list is obtained directly from gen_event.
    
    COUCHDB-2970

----


> config:set("log","level",...) fails to change lager backend levels
> ------------------------------------------------------------------
>
>                 Key: COUCHDB-2970
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2970
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Logging
>            Reporter: Jay Doane
>
> The following remsh session shows that at first, both config log level and lager_file_backend levels are the same (info), but after we use config to change the level to notice, the lager level remains at info:
> {code}
> (cloudant@db1.v)26> config:get("log","level").
> "info"
> (cloudant@db1.v)27> gen_event:which_handlers(lager_event).
> [{lager_file_backend,"/var/log/cloudant/cloudant.log"},
>  lager_backend_throttle]
> (cloudant@db1.v)28> lager:get_loglevel({lager_file_backend,"/var/log/cloudant/cloudant.log"}).
> info
> (cloudant@db1.v)29> config:set("log","level","notice",false).
> ok
> (cloudant@db1.v)30> lager:get_loglevel({lager_file_backend,"/var/log/cloudant/cloudant.log"}).
> info
> {code}
> The problem occurs because https://github.com/apache/couchdb-couch-log-lager/blob/master/src/couch_log_lager.erl#L67 obtains the handlers from application:get_env(lager, handlers), which returns the a structure defined in sys.config, but it should use gen_event:which_handlers(lager_event), which returns the actual list of handlers:
> {code}
> (cloudant@db1.v)31> application:get_env(lager, handlers).                                
> {ok,[{lager_file_backend,
>          [{file,"/var/log/cloudant/cloudant.log"},
>           {formatter,lager_default_formatter},
>           {formatter_config,
>               [date," ",time," [",severity,"] ",node," ",pid," ",message,
>                "\n"]}]}]}
> (cloudant@db1.v)32> gen_event:which_handlers(lager_event).                               [{lager_file_backend,"/var/log/cloudant/cloudant.log"},
>  lager_backend_throttle]
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)