diff options
author | Randall Leeds <randall@apache.org> | 2013-01-26 10:34:58 -0800 |
---|---|---|
committer | Randall Leeds <randall@apache.org> | 2013-01-26 10:40:25 -0800 |
commit | acd5f68764b09bd7752ae4924324b11f5c30cfd8 (patch) | |
tree | b972762b9f3806a1ed106624a1551fde1007ffa8 | |
parent | 2a7816eefac02dfcf97d7ef52887c2f0face6050 (diff) | |
download | couchdb-acd5f68764b09bd7752ae4924324b11f5c30cfd8.tar.gz |
Squashed merge of 1569-feature-low-disk-space-warn:
commit de76884544f95fdaf3492a2f88899d7e1fd41326
Author: Randall Leeds <randall@apache.org>
Date: Sat Jan 26 10:34:04 2013 -0800
export the new warn log funs
commit e71cf0499788553f457275558aaf3658fd74fe81
Author: Randall Leeds <randall@apache.org>
Date: Sat Jan 26 10:33:15 2013 -0800
fix mistake in ?LOG_WARN
commit 5abc82b79e93a089b942dfabefb57e57fc243207
Author: Randall Leeds <randall@apache.org>
Date: Sat Jan 26 10:12:58 2013 -0800
change low disk space message to warn level
closes COUCHDB-1569
commit a1461a2b92f8cbd89f0aebe7339e754836d14202
Author: Randall Leeds <randall@apache.org>
Date: Sat Jan 26 09:59:03 2013 -0800
add a ?LOG_WARN and warning level for couch_log
-rw-r--r-- | src/couchdb/couch_compaction_daemon.erl | 4 | ||||
-rw-r--r-- | src/couchdb/couch_db.hrl | 7 | ||||
-rw-r--r-- | src/couchdb/couch_log.erl | 24 |
3 files changed, 29 insertions, 6 deletions
diff --git a/src/couchdb/couch_compaction_daemon.erl b/src/couchdb/couch_compaction_daemon.erl index bc8cfea5d..18a51a412 100644 --- a/src/couchdb/couch_compaction_daemon.erl +++ b/src/couchdb/couch_compaction_daemon.erl @@ -302,7 +302,7 @@ can_db_compact(#config{db_frag = Threshold} = Config, Db) -> true -> true; false -> - ?LOG_INFO("Compaction daemon - skipping database `~s` " + ?LOG_WARN("Compaction daemon - skipping database `~s` " "compaction: the estimated necessary disk space is about ~p" " bytes but the currently available disk space is ~p bytes.", [Db#db.name, SpaceRequired, Free]), @@ -333,7 +333,7 @@ can_view_compact(Config, DbName, GroupId, GroupInfo) -> true -> true; false -> - ?LOG_INFO("Compaction daemon - skipping view group `~s` " + ?LOG_WARN("Compaction daemon - skipping view group `~s` " "compaction (database `~s`): the estimated necessary " "disk space is about ~p bytes but the currently available" " disk space is ~p bytes.", diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl index 325fb98ce..42f10ac77 100644 --- a/src/couchdb/couch_db.hrl +++ b/src/couchdb/couch_db.hrl @@ -50,6 +50,13 @@ false -> ok end). +-define(LOG_WARN(Format, Args), + case couch_log:warn_on(?MODULE) of + true -> + couch_log:warn(Format, Args); + false -> ok + end). + -define(LOG_ERROR(Format, Args), couch_log:error(Format, Args)). % Tree::term() is really a tree(), but we don't want to require R13B04 yet diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl index 906a8beba..cd4bbbb8b 100644 --- a/src/couchdb/couch_log.erl +++ b/src/couchdb/couch_log.erl @@ -15,16 +15,17 @@ % public API -export([start_link/0, stop/0]). --export([debug/2, info/2, error/2]). --export([debug_on/0, info_on/0, get_level/0, get_level_integer/0, set_level/1]). --export([debug_on/1, info_on/1, get_level/1, get_level_integer/1, set_level/2]). +-export([debug/2, info/2, warn/2, error/2]). +-export([debug_on/0, info_on/0, warn_on/0, get_level/0, get_level_integer/0, set_level/1]). +-export([debug_on/1, info_on/1, warn_on/1, get_level/1, get_level_integer/1, set_level/2]). -export([read/2]). % gen_event callbacks -export([init/1, handle_event/2, terminate/2, code_change/3]). -export([handle_info/2, handle_call/2]). --define(LEVEL_ERROR, 3). +-define(LEVEL_ERROR, 4). +-define(LEVEL_WARN, 3). -define(LEVEL_INFO, 2). -define(LEVEL_DEBUG, 1). @@ -42,17 +43,23 @@ info(Format, Args) -> {ConsoleMsg, FileMsg} = get_log_messages(self(), info, Format, Args), gen_event:sync_notify(error_logger, {couch_info, ConsoleMsg, FileMsg}). +warn(Format, Args) -> + {ConsoleMsg, FileMsg} = get_log_messages(self(), warn, Format, Args), + gen_event:sync_notify(error_logger, {couch_warn, ConsoleMsg, FileMsg}). + error(Format, Args) -> {ConsoleMsg, FileMsg} = get_log_messages(self(), error, Format, Args), gen_event:sync_notify(error_logger, {couch_error, ConsoleMsg, FileMsg}). level_integer(error) -> ?LEVEL_ERROR; +level_integer(warn) -> ?LEVEL_WARN; level_integer(info) -> ?LEVEL_INFO; level_integer(debug) -> ?LEVEL_DEBUG; level_integer(_Else) -> ?LEVEL_ERROR. % anything else default to ERROR level level_atom(?LEVEL_ERROR) -> error; +level_atom(?LEVEL_WARN) -> warn; level_atom(?LEVEL_INFO) -> info; level_atom(?LEVEL_DEBUG) -> debug. @@ -110,12 +117,18 @@ debug_on() -> info_on() -> get_level_integer() =< ?LEVEL_INFO. +warn_on() -> + get_level_integer() =< ?LEVEL_WARN. + debug_on(Module) -> get_level_integer(Module) =< ?LEVEL_DEBUG. info_on(Module) -> get_level_integer(Module) =< ?LEVEL_INFO. +warn_on(Module) -> + get_level_integer(Module) =< ?LEVEL_WARN. + set_level(LevelAtom) -> set_level_integer(level_integer(LevelAtom)). @@ -153,6 +166,9 @@ set_level_integer(Module, Int) -> handle_event({couch_error, ConMsg, FileMsg}, State) -> log(State, ConMsg, FileMsg), {ok, State}; +handle_event({couch_warn, ConMsg, FileMsg}, State) -> + log(State, ConMsg, FileMsg), + {ok, State}; handle_event({couch_info, ConMsg, FileMsg}, State) -> log(State, ConMsg, FileMsg), {ok, State}; |