Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error reason specific logging to hello_registry. #86

Merged
merged 1 commit into from
Nov 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@
#### 5600

* ___Messages___:
* [bb0ea6d2b9c74a78afa724889ceee0b5] Hello registry received @EXIT@ signal from monitored process @PID@ with reason @REASON@.
* [da5cd3be4435462dafff47b1bbc34a62] Hello registry received @EXIT@ signal from monitored process @PID@ with reason @REASON@. Going to clean up associated processes @PIDS@.
* [aca4e83479364c4cb779bcc2be1a810b] Hello registry : Received @EXIT@ from process @PID@ with reason @REASON@.
* [bb0ea6d2b9c74a78afa724889ceee0b5] Hello registry : Received @EXIT@ from process @PID@ with reason 'normal'.
* [d8f19a4f217f4a2f958f4bc3ddffaa0d] Hello registry : Received @EXIT@ from process @PID@ with reason 'normal'.
* [da5cd3be4435462dafff47b1bbc34a62] Hello registry : Received @EXIT@ from process @PID@ with reason @REASON@. Cleaning up associated processes @PIDS@.
* [ab5f921ed6e7488293241dc27eaf102e] Hello registry attempted to register process @PID@ with key @KEY@, but process is not alive.
* ___Explanation___: Hello registry noticed problems in registering or monitoring processes.
* ___Level___: info
Expand Down
2 changes: 2 additions & 0 deletions include/hello_log_ids.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
-define(LOGID55, {ab5f921ed6e7488293241dc27eaf102e, 5600}).
-define(LOGID56, {b5886b31a45d422bb02422aaf072797b, 5500}).
-define(LOGID57, {af5e3e79776642e4851709b58e7ea790, 2400}).
-define(LOGID65, {d8f19a4f217f4a2f958f4bc3ddffaa0d, 5600}).
-define(LOGID66, {aca4e83479364c4cb779bcc2be1a810b, 5600}).

%MESSAGE IDs and SATUS CODEs for hello_service
-define(LOGID58, {eda0efbe7f6d490490e00ae4055629d2, 5400}).
Expand Down
18 changes: 14 additions & 4 deletions src/hello_registry.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,24 @@ handle_call({unregister, Key}, _From, Table) ->
handle_call(_Call, _From, State) ->
{reply, {error, unknown_call}, State}.

handle_info({'EXIT', From, normal}, Table) ->
?LOG_DEBUG("Hello registry : Received 'EXIT' from process ~p with reason 'normal'.", [From],
[{hello_error_reason, {process_exit, normal}}], ?LOGID51),
{noreply, Table};
handle_info({'EXIT', From, Reason}, Table) ->
?LOG_ERROR("Hello registry : Received 'EXIT' signal from monitored process ~p with reason ~p.", [From, Reason],
[{hello_error_reason, {process_exit, Reason}}], ?LOGID51),
?LOG_ERROR("Hello registry : Received 'EXIT' from process ~p with reason ~p.", [From, Reason],
[{hello_error_reason, {process_exit, Reason}}], ?LOGID66),
{noreply, Table};
handle_info({'DOWN', _MRef, process, Pid, Reason}, Table) ->
Objects = ets:match(Table, {'$1', Pid, '_', '_'}),
?LOG_ERROR("Hello registry : Received 'DOWN' signal from monitored process ~p with reason ~p. Going to clean up associated processes ~p.",
[Pid, Reason, Objects], [{hello_error_reason, {process_down, Objects, Reason}}], ?LOGID52),
case Reason of
normal ->
?LOG_DEBUG("Hello registry : Received 'DOWN' from process ~p with reason 'normal'.",
[Pid], [{hello_error_reason, {process_down, Objects, Reason}}], ?LOGID65);
_ ->
?LOG_ERROR("Hello registry : Received 'DOWN' from process ~p with reason ~p. Cleaning up associated processes ~p.",
[Pid, Reason, Objects], [{hello_error_reason, {process_down, Objects, Reason}}], ?LOGID52)
end,
spawn(fun() -> [down(Object)|| Object <- Objects] end),
{noreply, Table};
handle_info({dnssd, _Ref, Msg}, State) ->
Expand Down