diff --git a/apps/iot/src/consumer/iot_zd_consumer.erl b/apps/iot/src/consumer/iot_zd_consumer.erl index 7577712..3e9a2fb 100644 --- a/apps/iot/src/consumer/iot_zd_consumer.erl +++ b/apps/iot/src/consumer/iot_zd_consumer.erl @@ -158,8 +158,21 @@ handle_info({directive_reply, Reply}, State = #state{logger_pid = LoggerPid, fli FlightInfo = <<"flight_num: ", (integer_to_binary(FlightNum - 1))/binary>>, case Reply of {ok, RawReq, DirectiveResult} -> + case DirectiveResult of + ok -> + iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, <<"OK">>, FlightInfo]); + {ok, Response} when is_binary(Response) -> + iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, Response, FlightInfo]); + {error, Reason0} -> + Reason = if + is_atom(Reason0) -> atom_to_binary(Reason0); + is_binary(Reason0) -> Reason0; + true -> <<"Unknow error">> + end, + iot_logger:write(LoggerPid, [<<"[error]">>, RawReq, Reason, FlightInfo]) + end, iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, DirectiveResult, FlightInfo]); - {error, RawReq, Error} -> + {error, RawReq, Error} when is_binary(Error) -> iot_logger:write(LoggerPid, [<<"[error]">>, RawReq, Error, FlightInfo]) end, {noreply, State#state{flight_num = FlightNum - 1}};