From 8d31462be5b6931d3004f7cd56cb35736cfb1558 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 31 Aug 2023 23:20:53 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20gen=5Fbehaviour=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=BA=A0=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gen_apu.erl | 80 ++++++++++++++----- src/gen_emm.erl | 46 ++--------- src/gen_ipc.erl | 200 +++++++++++++++++++++++++++++++++++++++++++++++- src/gen_mpp.erl | 80 +++++++++++++------ src/gen_srv.erl | 82 ++++++++++++++------ 5 files changed, 378 insertions(+), 110 deletions(-) diff --git a/src/gen_apu.erl b/src/gen_apu.erl index 5e62178..fe15930 100644 --- a/src/gen_apu.erl +++ b/src/gen_apu.erl @@ -1304,9 +1304,20 @@ limit_report(#{label := {gen_apu, terminate}, reason => io_lib:limit_term(Reason, Depth), client_info => limit_client_report(Client, Depth) }; -limit_report(#{label := {gen_apu, no_handle_info}, - message := Msg} = Report, Depth) -> - Report#{message => io_lib:limit_term(Msg, Depth)}. +limit_report(#{label := {gen_apu, inner_error}, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client} = Report, + Depth) -> + Report#{ + last_message => io_lib:limit_term(Msg, Depth), + state => io_lib:limit_term(State, Depth), + log => [io_lib:limit_term(L, Depth) || L <- Log], + reason => io_lib:limit_term(Reason, Depth), + client_info => limit_client_report(Client, Depth) + }. limit_client_report({From, {Name, Stacktrace}}, Depth) -> {From, {Name, io_lib:limit_term(Stacktrace, Depth)}}; @@ -1340,7 +1351,7 @@ format_log_single(#{label := {gen_apu, terminate}, client_info := Client}, #{single_line := true, depth := Depth} = FormatOpts) -> P = p(FormatOpts), - Format1 = lists:append(["Generic server ", P, " terminating. Reason: ", P, + Format1 = lists:append(["gen_apu ", P, " terminating. Reason: ", P, ". Last message: ", P, ". State: ", P, "."]), {ServerLogFormat, ServerLogArgs} = format_server_log_single(Log, FormatOpts), {ClientLogFormat, ClientLogArgs} = format_client_log_single(Client, FormatOpts), @@ -1354,21 +1365,29 @@ format_log_single(#{label := {gen_apu, terminate}, end, {Format1 ++ ServerLogFormat ++ ClientLogFormat, Args1 ++ ServerLogArgs ++ ClientLogArgs}; -format_log_single(#{label := {gen_apu, no_handle_info}, - module := Module, - message := Msg}, +format_log_single(#{label := {gen_apu, inner_error}, + name := Name, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client}, #{single_line := true, depth := Depth} = FormatOpts) -> P = p(FormatOpts), - Format = lists:append(["Undefined handle_info in ", P, - ". Unhandled message: ", P, "."]), - Args = + Format1 = lists:append(["gen_apu ", P, " inner_error. Reason: ", P, + ". Last message: ", P, ". State: ", P, "."]), + {ServerLogFormat, ServerLogArgs} = format_server_log_single(Log, FormatOpts), + {ClientLogFormat, ClientLogArgs} = format_client_log_single(Client, FormatOpts), + + Args1 = case Depth of unlimited -> - [Module, Msg]; + [Name, fix_reason(Reason), Msg, State]; _ -> - [Module, Depth, Msg, Depth] + [Name, Depth, fix_reason(Reason), Depth, Msg, Depth, State, Depth] end, - {Format, Args}; + {Format1 ++ ServerLogFormat ++ ClientLogFormat, + Args1 ++ ServerLogArgs ++ ClientLogArgs}; format_log_single(Report, FormatOpts) -> format_log_multi(Report, FormatOpts). @@ -1385,7 +1404,7 @@ format_log_multi(#{label := {gen_apu, terminate}, P = p(FormatOpts), Format = lists:append( - ["** Generic server ", P, " terminating \n" + ["** gen_apu ", P, " terminating \n" "** Last message in was ", P, "~n" "** When Server state == ", P, "~n" "** Reason for termination ==~n** ", P, "~n"] ++ @@ -1407,20 +1426,39 @@ format_log_multi(#{label := {gen_apu, terminate}, end ++ ClientArgs end, {Format, Args}; -format_log_multi(#{label := {gen_apu, no_handle_info}, - module := Module, - message := Msg}, +format_log_multi(#{label := {gen_apu, inner_error}, + name := Name, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client}, #{depth := Depth} = FormatOpts) -> + Reason1 = fix_reason(Reason), + {ClientFmt, ClientArgs} = format_client_log(Client, FormatOpts), P = p(FormatOpts), Format = - "** Undefined handle_info in ~p~n" - "** Unhandled message: " ++ P ++ "~n", + lists:append( + ["** gen_apu ", P, " inner_error \n" + "** Last message in was ", P, "~n" + "** When Server state == ", P, "~n" + "** Reason for termination ==~n** ", P, "~n"] ++ + case Log of + [] -> []; + _ -> ["** Log ==~n** [" | + lists:join(",~n ", lists:duplicate(length(Log), P))] ++ + ["]~n"] + end) ++ ClientFmt, Args = case Depth of unlimited -> - [Module, Msg]; + [Name, Msg, State, Reason1] ++ Log ++ ClientArgs; _ -> - [Module, Msg, Depth] + [Name, Depth, Msg, Depth, State, Depth, Reason1, Depth] ++ + case Log of + [] -> []; + _ -> lists:flatmap(fun(L) -> [L, Depth] end, Log) + end ++ ClientArgs end, {Format, Args}. diff --git a/src/gen_emm.erl b/src/gen_emm.erl index cc2d343..6b6daae 100644 --- a/src/gen_emm.erl +++ b/src/gen_emm.erl @@ -932,7 +932,7 @@ format_log(Report) -> limit_report(Report, unlimited) -> Report; -limit_report(#{label := {gen_event, terminate}, +limit_report(#{label := {gen_emm, epm_terminate}, last_message := LastIn, state := State, reason := Reason} = Report, @@ -941,9 +941,7 @@ limit_report(#{label := {gen_event, terminate}, last_message => io_lib:limit_term(LastIn, Depth), state => io_lib:limit_term(State, Depth), reason => io_lib:limit_term(Reason, Depth) - }; -limit_report(#{label := {gen_event, no_handle_info}, message := Msg} = Report, Depth) -> - Report#{message => io_lib:limit_term(Msg, Depth)}. + }. %% format_log/2 is the report callback for any Logger handler, except %% error_logger. @@ -965,7 +963,7 @@ format_log(Report, FormatOpts0) -> {Format, Args} = format_log_single(Report, FormatOpts), io_lib:format(Format, Args, IoOpts). -format_log_single(#{label := {gen_event, terminate}, +format_log_single(#{label := {gen_emm, epm_terminate}, handler := Handler, name := SName, last_message := LastIn, @@ -985,25 +983,9 @@ format_log_single(#{label := {gen_event, terminate}, [Handler, Depth, SName, Depth, Reason1, Depth, LastIn, Depth, State, Depth] end, - {Format1, Args1}; -format_log_single(#{label := {gen_event, no_handle_info}, - module := Mod, - message := Msg}, - #{single_line := true, depth := Depth} = FormatOpts) -> - P = p(FormatOpts), - Format = lists:append(["Undefined handle_info in ", P, ". Unhandled message: ", P, "."]), - Args = - case Depth of - unlimited -> - [Mod, Msg]; - _ -> - [Mod, Depth, Msg, Depth] - end, - {Format, Args}; -format_log_single(Report, FormatOpts) -> - format_log_multi(Report, FormatOpts). + {Format1, Args1}. -format_log_multi(#{label := {gen_event, terminate}, +format_log_multi(#{label := {gen_emm, epm_terminate}, handler := Handler, name := SName, last_message := LastIn, @@ -1013,7 +995,7 @@ format_log_multi(#{label := {gen_event, terminate}, Reason1 = fix_reason(Reason), P = p(FormatOpts), Format = - lists:append(["** gen_event handler ", P, " crashed.\n", + lists:append(["** gen_emm handler ", P, " crashed.\n", "** Was installed in ", P, "\n", "** Last event was: ", P, "\n", "** When handler state == ", P, "\n", @@ -1025,22 +1007,6 @@ format_log_multi(#{label := {gen_event, terminate}, _ -> [Handler, Depth, SName, Depth, LastIn, Depth, State, Depth, Reason1, Depth] end, - {Format, Args}; -format_log_multi(#{label := {gen_event, no_handle_info}, - module := Mod, - message := Msg}, - #{depth := Depth} = FormatOpts) -> - P = p(FormatOpts), - Format = - "** Undefined handle_info in ~p\n" - "** Unhandled message: " ++ P ++ "\n", - Args = - case Depth of - unlimited -> - [Mod, Msg]; - _ -> - [Mod, Msg, Depth] - end, {Format, Args}. fix_reason({'EXIT', {undef, [{M, F, A, _L} | _] = MFAs} = Reason}) -> diff --git a/src/gen_ipc.erl b/src/gen_ipc.erl index 53630d2..09e6181 100644 --- a/src/gen_ipc.erl +++ b/src/gen_ipc.erl @@ -1193,10 +1193,8 @@ epm_log(#{label := {gen_ipc, epm_terminate}, handler := Handler, name := SName, "** Was installed in ~tp~n" "** Last event was: ~tp~n" "** When handler state == ~tp~n" - "** Reason == ~tp~n", [Handler, SName, LastIn, State, Reason1]}; -epm_log(#{label := {gen_ipc, no_handle_info}, module := Module, message := Msg}) -> - {"** Undefined handle_info in ~tp~n" - "** Unhandled message: ~tp~n", [Module, Msg]}. + "** Reason == ~tp~n", [Handler, SName, LastIn, State, Reason1]}. + epmStopAll(EpmHers) -> allStop(iterator(EpmHers)). @@ -2276,6 +2274,48 @@ limit_report( client_info := ClientInfo } = Report, Depth) -> + Report#{ + queue => + case Q of + [Event | Events] -> + [io_lib:limit_term(Event, Depth) | io_lib:limit_term(Events, Depth)]; + _ -> + [] + end, + postponed => + case Postponed of + [] -> []; + _ -> io_lib:limit_term(Postponed, Depth) + end, + modules => io_lib:limit_term(Module, Depth), + status => io_lib:limit_term(FmtData, Depth), + timeouts => + case Timeouts of + {0, _} -> Timeouts; + _ -> io_lib:limit_term(Timeouts, Depth) + end, + log => + case Log of + [] -> []; + _ -> [io_lib:limit_term(T, Depth) || T <- Log] + end, + reason => + {Class, io_lib:limit_term(Reason, Depth), io_lib:limit_term(Stacktrace, Depth)}, + client_info => limit_client_info(ClientInfo, Depth) + }; +limit_report( + #{ + label := {gen_ipc, inner_error}, + queue := Q, + postponed := Postponed, + module := Module, + status := FmtData, + timeouts := Timeouts, + log := Log, + reason := {Class, Reason, Stacktrace}, + client_info := ClientInfo + } = Report, + Depth) -> Report#{ queue => case Q of @@ -2387,9 +2427,161 @@ format_log_single( lists:flatmap(fun(A) -> [A, Depth] end, Args0) end, {Format ++ ClientFmt, Args ++ ClientArgs}; +format_log_single( + #{ + label := {gen_ipc, inner_error}, + name := Name, + queue := Q, + %% postponed + %% isEnter + status := FmtData, + %% timeouts + log := Log, + reason := {Class, Reason, Stacktrace}, + client_info := ClientInfo + }, + #{single_line := true, depth := Depth} = FormatOpts) -> + P = p(FormatOpts), + {FixedReason, FixedStacktrace} = fix_reason(Class, Reason, Stacktrace), + {ClientFmt, ClientArgs} = format_client_log_single(ClientInfo, P, Depth), + Format = + lists:append( + ["State machine ", P, " inner_error. Reason: ", P, + case FixedStacktrace of + [] -> ""; + _ -> ". Stack: " ++ P + end, + case Q of + [] -> ""; + _ -> ". Last event: " ++ P + end, + ". State: ", P, + case Log of + [] -> ""; + _ -> ". Log: " ++ P + end, + "."] + ), + Args0 = + [Name, FixedReason] ++ + case FixedStacktrace of + [] -> []; + _ -> [FixedStacktrace] + end ++ + case Q of + [] -> []; + [Event | _] -> [Event] + end ++ + [FmtData] ++ + case Log of + [] -> []; + _ -> [Log] + end, + Args = + case Depth of + unlimited -> + Args0; + _ -> + lists:flatmap(fun(A) -> [A, Depth] end, Args0) + end, + {Format ++ ClientFmt, Args ++ ClientArgs}; format_log_single(Report, FormatOpts) -> format_log_multi(Report, FormatOpts). +format_log_multi( + #{ + label := {gen_ipc, terminate}, + name := Name, + queue := Q, + postponed := Postponed, + module := Module, + isEnter := StateEnter, + status := FmtData, + timeouts := Timeouts, + log := Log, + reason := {Class, Reason, Stacktrace}, + client_info := ClientInfo + }, + #{depth := Depth} = FormatOpts) -> + P = p(FormatOpts), + {FixedReason, FixedStacktrace} = fix_reason(Class, Reason, Stacktrace), + {ClientFmt, ClientArgs} = format_client_log(ClientInfo, P, Depth), + CBMode = + case StateEnter of + true -> + [Module, 'isEnter=true']; + false -> + Module + end, + Format = + lists:append( + ["** gen_ipc State machine ", P, " inner_error~n", + case Q of + [] -> ""; + _ -> "** Last event = " ++ P ++ "~n" + end, + "** When server status = ", P, "~n", + "** Reason for termination = ", P, ":", P, "~n", + "** Callback modules = ", P, "~n", + "** Callback mode = ", P, "~n", + case Q of + [_, _ | _] -> "** Queued = " ++ P ++ "~n"; + _ -> "" + end, + case Postponed of + [] -> ""; + _ -> "** Postponed = " ++ P ++ "~n" + end, + case FixedStacktrace of + [] -> ""; + _ -> "** Stacktrace =~n** " ++ P ++ "~n" + end, + case Timeouts of + {0, _} -> ""; + _ -> "** Time-outs: " ++ P ++ "~n" + end, + case Log of + [] -> ""; + _ -> "** Log =~n** " ++ P ++ "~n" + end]), + Args0 = + [Name | + case Q of + [] -> []; + [Event | _] -> [Event] + end] ++ + [FmtData, + Class, FixedReason, + Module, + CBMode] ++ + case Q of + [_ | [_ | _] = Events] -> [Events]; + _ -> [] + end ++ + case Postponed of + [] -> []; + _ -> [Postponed] + end ++ + case FixedStacktrace of + [] -> []; + _ -> [FixedStacktrace] + end ++ + case Timeouts of + {0, _} -> []; + _ -> [Timeouts] + end ++ + case Log of + [] -> []; + _ -> [Log] + end, + Args = + case Depth of + unlimited -> + Args0; + _ -> + lists:flatmap(fun(A) -> [A, Depth] end, Args0) + end, + {Format ++ ClientFmt, Args ++ ClientArgs}; format_log_multi( #{ label := {gen_ipc, terminate}, diff --git a/src/gen_mpp.erl b/src/gen_mpp.erl index ce59768..0f04a99 100644 --- a/src/gen_mpp.erl +++ b/src/gen_mpp.erl @@ -1205,9 +1205,20 @@ limit_report(#{label := {gen_mpp, terminate}, reason => io_lib:limit_term(Reason, Depth), client_info => limit_client_report(Client, Depth) }; -limit_report(#{label := {gen_mpp, no_handle_info}, - message := Msg} = Report, Depth) -> - Report#{message => io_lib:limit_term(Msg, Depth)}. +limit_report(#{label := {gen_mpp, inner_error}, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client} = Report, + Depth) -> + Report#{ + last_message => io_lib:limit_term(Msg, Depth), + state => io_lib:limit_term(State, Depth), + log => [io_lib:limit_term(L, Depth) || L <- Log], + reason => io_lib:limit_term(Reason, Depth), + client_info => limit_client_report(Client, Depth) + }. limit_client_report({From, {Name, Stacktrace}}, Depth) -> {From, {Name, io_lib:limit_term(Stacktrace, Depth)}}; @@ -1253,23 +1264,29 @@ format_log_single(#{label := {gen_mpp, terminate}, _ -> [Name, Depth, fix_reason(Reason), Depth, Msg, Depth, State, Depth] end, - {Format1 ++ ServerLogFormat ++ ClientLogFormat, - Args1 ++ ServerLogArgs ++ ClientLogArgs}; -format_log_single(#{label := {gen_mpp, no_handle_info}, - module := Module, - message := Msg}, + {Format1 ++ ServerLogFormat ++ ClientLogFormat, Args1 ++ ServerLogArgs ++ ClientLogArgs}; +format_log_single(#{label := {gen_mpp, inner_error}, + name := Name, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client}, #{single_line := true, depth := Depth} = FormatOpts) -> P = p(FormatOpts), - Format = lists:append(["Undefined handle_info in ", P, - ". Unhandled message: ", P, "."]), - Args = + Format1 = lists:append(["Generic server ", P, " terminating. Reason: ", P, + ". Last message: ", P, ". State: ", P, "."]), + {ServerLogFormat, ServerLogArgs} = format_server_log_single(Log, FormatOpts), + {ClientLogFormat, ClientLogArgs} = format_client_log_single(Client, FormatOpts), + + Args1 = case Depth of unlimited -> - [Module, Msg]; + [Name, fix_reason(Reason), Msg, State]; _ -> - [Module, Depth, Msg, Depth] + [Name, Depth, fix_reason(Reason), Depth, Msg, Depth, State, Depth] end, - {Format, Args}; + {Format1 ++ ServerLogFormat ++ ClientLogFormat, Args1 ++ ServerLogArgs ++ ClientLogArgs}; format_log_single(Report, FormatOpts) -> format_log_multi(Report, FormatOpts). @@ -1286,7 +1303,7 @@ format_log_multi(#{label := {gen_mpp, terminate}, P = p(FormatOpts), Format = lists:append( - ["** Generic server ", P, " terminating \n" + ["** gen_mpp ", P, " terminating \n" "** Last message in was ", P, "~n" "** When Server state == ", P, "~n" "** Reason for termination ==~n** ", P, "~n"] ++ @@ -1308,20 +1325,39 @@ format_log_multi(#{label := {gen_mpp, terminate}, end ++ ClientArgs end, {Format, Args}; -format_log_multi(#{label := {gen_mpp, no_handle_info}, - module := Module, - message := Msg}, +format_log_multi(#{label := {gen_mpp, inner_error}, + name := Name, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client}, #{depth := Depth} = FormatOpts) -> + Reason1 = fix_reason(Reason), + {ClientFmt, ClientArgs} = format_client_log(Client, FormatOpts), P = p(FormatOpts), Format = - "** Undefined handle_info in ~p~n" - "** Unhandled message: " ++ P ++ "~n", + lists:append( + ["** gen_mpp ", P, " inner_error \n" + "** Last message in was ", P, "~n" + "** When Server state == ", P, "~n" + "** Reason for termination ==~n** ", P, "~n"] ++ + case Log of + [] -> []; + _ -> ["** Log ==~n** [" | + lists:join(",~n ", lists:duplicate(length(Log), P))] ++ + ["]~n"] + end) ++ ClientFmt, Args = case Depth of unlimited -> - [Module, Msg]; + [Name, Msg, State, Reason1] ++ Log ++ ClientArgs; _ -> - [Module, Msg, Depth] + [Name, Depth, Msg, Depth, State, Depth, Reason1, Depth] ++ + case Log of + [] -> []; + _ -> lists:flatmap(fun(L) -> [L, Depth] end, Log) + end ++ ClientArgs end, {Format, Args}. diff --git a/src/gen_srv.erl b/src/gen_srv.erl index bf3b94c..db59551 100644 --- a/src/gen_srv.erl +++ b/src/gen_srv.erl @@ -1279,9 +1279,20 @@ limit_report(#{label := {gen_srv, terminate}, reason => io_lib:limit_term(Reason, Depth), client_info => limit_client_report(Client, Depth) }; -limit_report(#{label := {gen_srv, no_handle_info}, - message := Msg} = Report, Depth) -> - Report#{message => io_lib:limit_term(Msg, Depth)}. +limit_report(#{label := {gen_srv, inner_error}, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client} = Report, + Depth) -> + Report#{ + last_message => io_lib:limit_term(Msg, Depth), + state => io_lib:limit_term(State, Depth), + log => [io_lib:limit_term(L, Depth) || L <- Log], + reason => io_lib:limit_term(Reason, Depth), + client_info => limit_client_report(Client, Depth) + }. limit_client_report({From, {Name, Stacktrace}}, Depth) -> {From, {Name, io_lib:limit_term(Stacktrace, Depth)}}; @@ -1315,7 +1326,7 @@ format_log_single(#{label := {gen_srv, terminate}, client_info := Client}, #{single_line := true, depth := Depth} = FormatOpts) -> P = p(FormatOpts), - Format1 = lists:append(["Generic server ", P, " terminating. Reason: ", P, + Format1 = lists:append(["gen_srv ", P, " terminating. Reason: ", P, ". Last message: ", P, ". State: ", P, "."]), {ServerLogFormat, ServerLogArgs} = format_server_log_single(Log, FormatOpts), {ClientLogFormat, ClientLogArgs} = format_client_log_single(Client, FormatOpts), @@ -1327,23 +1338,29 @@ format_log_single(#{label := {gen_srv, terminate}, _ -> [Name, Depth, fix_reason(Reason), Depth, Msg, Depth, State, Depth] end, - {Format1 ++ ServerLogFormat ++ ClientLogFormat, - Args1 ++ ServerLogArgs ++ ClientLogArgs}; -format_log_single(#{label := {gen_srv, no_handle_info}, - module := Module, - message := Msg}, + {Format1 ++ ServerLogFormat ++ ClientLogFormat, Args1 ++ ServerLogArgs ++ ClientLogArgs}; +format_log_single(#{label := {gen_srv, inner_error}, + name := Name, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client}, #{single_line := true, depth := Depth} = FormatOpts) -> P = p(FormatOpts), - Format = lists:append(["Undefined handle_info in ", P, - ". Unhandled message: ", P, "."]), - Args = + Format1 = lists:append(["gen_srv ", P, " inner_error. Reason: ", P, + ". Last message: ", P, ". State: ", P, "."]), + {ServerLogFormat, ServerLogArgs} = format_server_log_single(Log, FormatOpts), + {ClientLogFormat, ClientLogArgs} = format_client_log_single(Client, FormatOpts), + + Args1 = case Depth of unlimited -> - [Module, Msg]; + [Name, fix_reason(Reason), Msg, State]; _ -> - [Module, Depth, Msg, Depth] + [Name, Depth, fix_reason(Reason), Depth, Msg, Depth, State, Depth] end, - {Format, Args}; + {Format1 ++ ServerLogFormat ++ ClientLogFormat, Args1 ++ ServerLogArgs ++ ClientLogArgs}; format_log_single(Report, FormatOpts) -> format_log_multi(Report, FormatOpts). @@ -1360,7 +1377,7 @@ format_log_multi(#{label := {gen_srv, terminate}, P = p(FormatOpts), Format = lists:append( - ["** Generic server ", P, " terminating \n" + ["** gen_srv ", P, " terminating \n" "** Last message in was ", P, "~n" "** When Server state == ", P, "~n" "** Reason for termination ==~n** ", P, "~n"] ++ @@ -1382,20 +1399,39 @@ format_log_multi(#{label := {gen_srv, terminate}, end ++ ClientArgs end, {Format, Args}; -format_log_multi(#{label := {gen_srv, no_handle_info}, - module := Module, - message := Msg}, +format_log_multi(#{label := {gen_srv, inner_error}, + name := Name, + last_message := Msg, + state := State, + log := Log, + reason := Reason, + client_info := Client}, #{depth := Depth} = FormatOpts) -> + Reason1 = fix_reason(Reason), + {ClientFmt, ClientArgs} = format_client_log(Client, FormatOpts), P = p(FormatOpts), Format = - "** Undefined handle_info in ~p~n" - "** Unhandled message: " ++ P ++ "~n", + lists:append( + ["** gen_srv ", P, " inner_error \n" + "** Last message in was ", P, "~n" + "** When Server state == ", P, "~n" + "** Reason for termination ==~n** ", P, "~n"] ++ + case Log of + [] -> []; + _ -> ["** Log ==~n** [" | + lists:join(",~n ", lists:duplicate(length(Log), P))] ++ + ["]~n"] + end) ++ ClientFmt, Args = case Depth of unlimited -> - [Module, Msg]; + [Name, Msg, State, Reason1] ++ Log ++ ClientArgs; _ -> - [Module, Msg, Depth] + [Name, Depth, Msg, Depth, State, Depth, Reason1, Depth] ++ + case Log of + [] -> []; + _ -> lists:flatmap(fun(L) -> [L, Depth] end, Log) + end ++ ClientArgs end, {Format, Args}.