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 2015/09/18 15:48:20 UTC

[2/3] couchdb-couch-log-lager git commit: Basic implementation

Basic implementation


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

Branch: refs/heads/master
Commit: 50dc85ffb99cf815b58a19b55b61d694a3a0137e
Parents: 2404298
Author: Eric Avdey <ei...@eiri.ca>
Authored: Thu Sep 17 18:43:13 2015 -0300
Committer: Eric Avdey <ei...@eiri.ca>
Committed: Thu Sep 17 18:43:13 2015 -0300

----------------------------------------------------------------------
 rebar.config                |  5 ++++
 src/couch_log_lager.app.src | 19 ++++++++++++++
 src/couch_log_lager.erl     | 55 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-log-lager/blob/50dc85ff/rebar.config
----------------------------------------------------------------------
diff --git a/rebar.config b/rebar.config
new file mode 100644
index 0000000..abc8b1b
--- /dev/null
+++ b/rebar.config
@@ -0,0 +1,5 @@
+{deps, [
+    {lager, ".*", {git, "https://git-wip-us.apache.org/repos/asf/couchdb-lager.git", {branch, "master"}}}
+]}.
+
+{erl_opts, [debug_info, {parse_transform, lager_transform}]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-log-lager/blob/50dc85ff/src/couch_log_lager.app.src
----------------------------------------------------------------------
diff --git a/src/couch_log_lager.app.src b/src/couch_log_lager.app.src
new file mode 100644
index 0000000..1cc9454
--- /dev/null
+++ b/src/couch_log_lager.app.src
@@ -0,0 +1,19 @@
+% 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.
+
+{application, couch_log_lager, [
+    {description, "CouchDB Log backend with lager"},
+    {vsn, git},
+    {modules, [couch_log_lager]},
+    {registered, []},
+    {applications, [kernel, stdlib, lager]}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-log-lager/blob/50dc85ff/src/couch_log_lager.erl
----------------------------------------------------------------------
diff --git a/src/couch_log_lager.erl b/src/couch_log_lager.erl
new file mode 100644
index 0000000..1938365
--- /dev/null
+++ b/src/couch_log_lager.erl
@@ -0,0 +1,55 @@
+% 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.
+
+-module(couch_log_lager).
+
+-behaviour(couch_log).
+
+-export([
+    debug/2,
+    info/2,
+    notice/2,
+    warning/2,
+    error/2,
+    critical/2,
+    alert/2,
+    emergency/2,
+    set_level/1
+]).
+
+debug(Fmt, Args) ->
+    lager:debug(Fmt, Args).
+
+info(Fmt, Args) ->
+    lager:info(Fmt, Args).
+
+notice(Fmt, Args) ->
+    lager:notice(Fmt, Args).
+
+warning(Fmt, Args) ->
+    lager:warning(Fmt, Args).
+
+error(Fmt, Args) ->
+    lager:error(Fmt, Args).
+
+critical(Fmt, Args) ->
+    lager:critical(Fmt, Args).
+
+alert(Fmt, Args) ->
+    lager:alert(Fmt, Args).
+
+emergency(Fmt, Args) ->
+    lager:emergency(Fmt, Args).
+
+set_level(Level) ->
+    {ok, Handlers} = application:get_env(lager, handlers),
+    [lager:set_loglevel(Handler, Level) || {Handler, _} <- Handlers].