Skip to content

Commit

Permalink
Set couchdb loglevel to the value specified in static_config.
Browse files Browse the repository at this point in the history
Change-Id: Ieda08326366879fc63f2eac7865edc3923b8875d
Reviewed-on: http://review.couchbase.org/10590
Tested-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
Reviewed-by: Dale Harvey <daleharvey@arandomurl.com>
Tested-by: Dale Harvey <daleharvey@arandomurl.com>
  • Loading branch information
aartamonau authored and Dale Harvey committed Nov 4, 2011
1 parent 5e7199d commit 4a981f9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion src/cb_suppress_loggers.erl → src/cb_init_loggers.erl
Expand Up @@ -13,14 +13,31 @@
%% See the License for the specific language governing permissions and
%% limitations under the License.

-module(cb_suppress_loggers).
-module(cb_init_loggers).

-export([start_link/0]).

start_link() ->
supress_loggers(),
set_couchdb_loglevel(),
ignore.

supress_loggers() ->
error_logger:delete_report_handler(error_logger_tty_h),
error_logger:delete_report_handler(sasl_report_tty_h).

set_couchdb_loglevel() ->
LogLevel = ns_server:get_loglevel(couchdb),
CouchLogLevel = ns_server_to_couchdb_loglevel(LogLevel),
couch_config:set("log", "level", CouchLogLevel).

ns_server_to_couchdb_loglevel(debug) ->
"debug";
ns_server_to_couchdb_loglevel(info) ->
"info";
ns_server_to_couchdb_loglevel(warn) ->
"error";
ns_server_to_couchdb_loglevel(error) ->
"error";
ns_server_to_couchdb_loglevel(critical) ->
"error".
2 changes: 1 addition & 1 deletion src/ns_server.erl
Expand Up @@ -17,7 +17,7 @@

-behavior(application).

-export([start/2, stop/1]).
-export([start/2, stop/1, get_loglevel/1]).

-include("ns_common.hrl").
-include_lib("ale/include/ale.hrl").
Expand Down
4 changes: 2 additions & 2 deletions src/ns_server_cluster_sup.erl
Expand Up @@ -52,8 +52,8 @@ init([]) ->
permanent, 5000, supervisor, [cb_couch_sup]},
%% this must be placed after cb_couch_sup since couchdb starts
%% sasl application
{cb_suppress_loggers, {cb_suppress_loggers, start_link, []},
transient, 1000, worker, [cb_supress_loggers]},
{cb_init_loggers, {cb_init_loggers, start_link, []},
transient, 1000, worker, [cb_init_loggers]},
{log_os_info, {log_os_info, start_link, []},
transient, 1000, worker, [log_os_info]},
{timeout_diag_logger, {timeout_diag_logger, start_link, []},
Expand Down

0 comments on commit 4a981f9

Please sign in to comment.