couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [05/29] twig commit: updated refs/heads/import to 2d56280
Date Mon, 03 Feb 2014 22:12:19 GMT
Replace keyfind with get_value wrapper


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

Branch: refs/heads/import
Commit: 14e3e0a6b14e31498cfb1b9a070dd53a9f98eece
Parents: 649e8cc
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Tue Mar 8 13:51:20 2011 -0500
Committer: Adam Kocoloski <adam@cloudant.com>
Committed: Tue Mar 8 13:51:20 2011 -0500

----------------------------------------------------------------------
 src/twig_event_handler.erl | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-twig/blob/14e3e0a6/src/twig_event_handler.erl
----------------------------------------------------------------------
diff --git a/src/twig_event_handler.erl b/src/twig_event_handler.erl
index 98735fc..1c83181 100644
--- a/src/twig_event_handler.erl
+++ b/src/twig_event_handler.erl
@@ -117,13 +117,13 @@ write(Level, {Format0, Args0}, State) ->
 message(_Pid, crash_report, Report) ->
     proc_lib:format(Report);
 message(Pid, supervisor_report, Report) ->
-    {_, Name} = lists:keyfind(supervisor, 1, Report),
-    {_, Error} = lists:keyfind(errorContext, 1, Report),
-    {_, Reason} = lists:keyfind(reason, 1, Report),
-    {_, Offender} = lists:keyfind(offender, 1, Report),
-    {_, ChildPid} = lists:keyfind(pid, 1, Offender),
-    {_, ChildName} = lists:keyfind(name, 1, Offender),
-    {M,F,_} = lists:keyfind(mfa, 1, Offender),
+    Name = get_value(supervisor, Report),
+    Error = get_value(errorContext, Report),
+    Reason = get_value(reason, Report),
+    Offender = get_value(offender, Report),
+    ChildPid = get_value(pid, Offender),
+    ChildName = get_value(name, Offender),
+    {M,F,_} = get_value(mfa, Offender),
     {"[~p] SUPERVISOR REPORT ~p ~p (~p) child: ~p [~p] ~p:~p",
         [Pid, Name, Error, Reason, ChildName, ChildPid, M, F]};
 message(Pid, progress_report, Report) ->
@@ -145,3 +145,11 @@ otp_event_level(error_report, _) ->                 ?LEVEL_ERR;
 otp_event_level(warning_report, _) ->               ?LEVEL_WARN;
 otp_event_level(info_report, _) ->                  ?LEVEL_INFO;
 otp_event_level(_, _) ->                            undefined.
+
+get_value(Key, Props) ->
+    case lists:keyfind(Key, 1, Props) of
+        {Key, Value} ->
+            Value;
+        undefined ->
+            undefined
+    end.


Mime
View raw message