summaryrefslogtreecommitdiff
path: root/src/couch_log/src/couch_log_util.erl
diff options
context:
space:
mode:
authorRussell Branca <chewbranca@apache.org>2023-05-04 14:47:59 -0700
committerGitHub <noreply@github.com>2023-05-04 14:47:59 -0700
commitf1ab0cabf84c48ac0da67a6574fb3dadd88eb7be (patch)
treecbea027dd77aa8976395ce407b3a026364358a11 /src/couch_log/src/couch_log_util.erl
parent17a99712ecfee2d1e02ec5ed57cbc82fd8a8493c (diff)
downloadcouchdb-f1ab0cabf84c48ac0da67a6574fb3dadd88eb7be.tar.gz
Add report logging (#4483)
Add new report logging mechanism to log a map of key/value pairs --------- Co-authored-by: ILYA Khlopotov <iilyak@apache.org>
Diffstat (limited to 'src/couch_log/src/couch_log_util.erl')
-rw-r--r--src/couch_log/src/couch_log_util.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/couch_log/src/couch_log_util.erl b/src/couch_log/src/couch_log_util.erl
index 8be11e12d..68aaa85ce 100644
--- a/src/couch_log/src/couch_log_util.erl
+++ b/src/couch_log/src/couch_log_util.erl
@@ -21,7 +21,9 @@
level_to_atom/1,
level_to_string/1,
- string_p/1
+ string_p/1,
+
+ maybe_format_type/1
]).
-include("couch_log.hrl").
@@ -29,6 +31,8 @@
-spec should_log(#log_entry{} | atom()) -> boolean().
should_log(#log_entry{level = Level}) ->
should_log(Level);
+should_log(report) ->
+ should_log(couch_log_config:get(report_level));
should_log(Level) ->
level_to_integer(Level) >= couch_log_config:get(level_int).
@@ -145,3 +149,10 @@ string_p1([]) ->
true;
string_p1(_) ->
false.
+
+maybe_format_type(#log_entry{type = undefined} = Entry) ->
+ Entry;
+maybe_format_type(#log_entry{type = Type, msg = ["[" | Msg]} = Entry) ->
+ Entry#log_entry{msg = ["[", Type, " " | Msg]};
+maybe_format_type(#log_entry{} = Entry) ->
+ Entry.