This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch ra
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7b2abf0f6e9be67013d2507af58300aa08b5bddc
Author: Robert Newson <[email protected]>
AuthorDate: Fri Sep 6 17:25:47 2024 +0100

    redirect logger output to couch_log
---
 src/couch/src/couch_app.erl                |  1 +
 src/couch_log/src/couch_logger_handler.erl | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/src/couch/src/couch_app.erl b/src/couch/src/couch_app.erl
index 2ee9ef716..fe6e48466 100644
--- a/src/couch/src/couch_app.erl
+++ b/src/couch/src/couch_app.erl
@@ -21,6 +21,7 @@
 ]).
 
 start(_Type, _) ->
+    logger:add_handler(couch_log, couch_logger_handler, #{}),
     RaEnv = [
         {data_dir, config:get("couchdb", "ra_data_dir")}
     ],
diff --git a/src/couch_log/src/couch_logger_handler.erl 
b/src/couch_log/src/couch_logger_handler.erl
new file mode 100644
index 000000000..fe9054937
--- /dev/null
+++ b/src/couch_log/src/couch_logger_handler.erl
@@ -0,0 +1,22 @@
+% 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_logger_handler).
+
+-export([log/2]).
+
+log(#{msg := {report, Report}} = LogEvent, Config) ->
+    log(LogEvent#{msg := {"report: ~p", [Report]}}, Config);
+log(#{msg := {string, Msg}} = LogEvent, Config) ->
+    log(LogEvent#{msg := {Msg, []}}, Config);
+log(#{level := Level, msg := {Fmt, Args}, meta := Meta}, _Config) ->
+    couch_log:Level(Fmt, Args).

Reply via email to