You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/09/15 19:10:42 UTC

couch-log commit: updated refs/heads/master to ab3943d

Repository: couchdb-couch-log
Updated Branches:
  refs/heads/master a1c9c00ed -> ab3943d57


Collect stats for log messages


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

Branch: refs/heads/master
Commit: ab3943d57ad49b28a234bd424f110b2dccddc161
Parents: a1c9c00
Author: Robert Newson <rn...@apache.org>
Authored: Mon Sep 15 18:07:43 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Mon Sep 15 18:07:43 2014 +0100

----------------------------------------------------------------------
 priv/stats_descriptions.cfg | 44 ++++++++++++++++++++++++++++++++++++++++
 src/couch_log.app.src       |  2 +-
 src/couch_log.erl           |  8 ++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-log/blob/ab3943d5/priv/stats_descriptions.cfg
----------------------------------------------------------------------
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
new file mode 100644
index 0000000..9350a9c
--- /dev/null
+++ b/priv/stats_descriptions.cfg
@@ -0,0 +1,44 @@
+%% 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.
+
+% Style guide for descriptions: Start with a lowercase letter & do not add
+% a trailing full-stop / period
+% Please keep this in alphabetical order
+
+{[couch_log, level, critical], [
+    {type, counter},
+    {desc, <<"number of logged critical messages">>}
+]}.
+{[couch_log, level, debug], [
+    {type, counter},
+    {desc, <<"number of logged debug messages">>}
+]}.
+{[couch_log, level, emergency], [
+    {type, counter},
+    {desc, <<"number of logged emergency messages">>}
+]}.
+{[couch_log, level, error], [
+    {type, counter},
+    {desc, <<"number of logged error messages">>}
+]}.
+{[couch_log, level, info], [
+    {type, counter},
+    {desc, <<"number of logged info messages">>}
+]}.
+{[couch_log, level, notice], [
+    {type, counter},
+    {desc, <<"number of logged notice messages">>}
+]}.
+{[couch_log, level, warning], [
+    {type, counter},
+    {desc, <<"number of logged warning messages">>}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-log/blob/ab3943d5/src/couch_log.app.src
----------------------------------------------------------------------
diff --git a/src/couch_log.app.src b/src/couch_log.app.src
index f8372ca..0231860 100644
--- a/src/couch_log.app.src
+++ b/src/couch_log.app.src
@@ -15,5 +15,5 @@
     {vsn, git},
     {modules, [couch_log]},
     {registered, []},
-    {applications, [kernel, stdlib, lager]}
+    {applications, [kernel, stdlib, lager, couch_stats]}
 ]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-log/blob/ab3943d5/src/couch_log.erl
----------------------------------------------------------------------
diff --git a/src/couch_log.erl b/src/couch_log.erl
index dd6f25e..9c5b7e8 100644
--- a/src/couch_log.erl
+++ b/src/couch_log.erl
@@ -15,25 +15,33 @@
 -export([debug/2, info/2, notice/2, warning/2, error/2, critical/2, alert/2, emergency/2]).
 
 debug(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, debug]),
     lager:debug(Fmt, Args).
 
 info(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, info]),
     lager:info(Fmt, Args).
 
 notice(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, notice]),
     lager:notice(Fmt, Args).
 
 warning(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, warning]),
     lager:warning(Fmt, Args).
 
 error(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, error]),
     lager:error(Fmt, Args).
 
 critical(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, critical]),
     lager:critical(Fmt, Args).
 
 alert(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, alert]),
     lager:alert(Fmt, Args).
 
 emergency(Fmt, Args) ->
+    couch_stats:increment_counter([couch_log, level, emergency]),
     lager:emergency(Fmt, Args).