couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rand...@apache.org
Subject [1/2] git commit: Squashed merge of 1569-feature-low-disk-space-warn:
Date Sat, 26 Jan 2013 18:42:03 GMT
Squashed merge of 1569-feature-low-disk-space-warn:

Backported from master

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


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/19c82720
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/19c82720
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/19c82720

Branch: refs/heads/1.3.x
Commit: 19c82720d339e2e91614096fa066f190d53ae426
Parents: 9a5de8d
Author: Randall Leeds <randall@apache.org>
Authored: Sat Jan 26 10:34:58 2013 -0800
Committer: Randall Leeds <randall@apache.org>
Committed: Sat Jan 26 10:40:15 2013 -0800

----------------------------------------------------------------------
 src/couchdb/couch_compaction_daemon.erl |    4 ++--
 src/couchdb/couch_db.hrl                |    7 +++++++
 src/couchdb/couch_log.erl               |   20 +++++++++++++++++---
 3 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/19c82720/src/couchdb/couch_compaction_daemon.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_compaction_daemon.erl b/src/couchdb/couch_compaction_daemon.erl
index bc8cfea..18a51a4 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.",

http://git-wip-us.apache.org/repos/asf/couchdb/blob/19c82720/src/couchdb/couch_db.hrl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl
index 65eb7f0..3b08de8 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

http://git-wip-us.apache.org/repos/asf/couchdb/blob/19c82720/src/couchdb/couch_log.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index fc7b393..21f02f7 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -15,15 +15,16 @@
 
 % 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/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([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).
 
@@ -41,17 +42,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.
 
@@ -101,6 +108,9 @@ debug_on() ->
 info_on() ->
     get_level_integer() =< ?LEVEL_INFO.
 
+warn_on() ->
+    get_level_integer() =< ?LEVEL_WARN.
+
 set_level(LevelAtom) ->
     set_level_integer(level_integer(LevelAtom)).
 
@@ -120,6 +130,10 @@ set_level_integer(Int) ->
 handle_event({couch_error, ConMsg, FileMsg}, State) ->
     log(State, ConMsg, FileMsg),
     {ok, State};
+handle_event({couch_warn, ConMsg, FileMsg}, #state{level = LogLevel} = State)
+when LogLevel =< ?LEVEL_WARN ->
+    log(State, ConMsg, FileMsg),
+    {ok, State};
 handle_event({couch_info, ConMsg, FileMsg}, #state{level = LogLevel} = State)
 when LogLevel =< ?LEVEL_INFO ->
     log(State, ConMsg, FileMsg),


Mime
View raw message