add debug

This commit is contained in:
anlicheng 2023-12-04 13:53:06 +08:00
parent 73ff03de9c
commit 714ec1e734
2 changed files with 4 additions and 5 deletions

View File

@ -501,10 +501,9 @@ code_change(_OldVsn, StateName, State = #state{}, _Extra) ->
handle_data(#{<<"device_uuid">> := DeviceUUID, <<"service_name">> := ServiceName, <<"at">> := Timestamp, <<"fields">> := FieldsList, <<"tags">> := Tags}, #state{uuid = UUID}) handle_data(#{<<"device_uuid">> := DeviceUUID, <<"service_name">> := ServiceName, <<"at">> := Timestamp, <<"fields">> := FieldsList, <<"tags">> := Tags}, #state{uuid = UUID})
when is_binary(DeviceUUID), DeviceUUID /= <<>> -> when is_binary(DeviceUUID), DeviceUUID /= <<>> ->
lager:debug("[iot_host] host: ~p, handle device data: ~p, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags]),
case iot_device:get_pid(DeviceUUID) of case iot_device:get_pid(DeviceUUID) of
undefined -> undefined ->
lager:warning("[iot_host] host uuid: ~p, device uuid: ~p not found, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags]),
ok; ok;
DevicePid when is_pid(DevicePid) -> DevicePid when is_pid(DevicePid) ->
case iot_device:is_activated(DevicePid) of case iot_device:is_activated(DevicePid) of
@ -518,7 +517,7 @@ handle_data(#{<<"device_uuid">> := DeviceUUID, <<"service_name">> := ServiceName
iot_device:change_status(DevicePid, ?DEVICE_ONLINE); iot_device:change_status(DevicePid, ?DEVICE_ONLINE);
false -> false ->
lager:notice("[iot_host] uuid: ~p, device_uuid: ~p, device is not activated", [UUID, DeviceUUID]) lager:warning("[iot_host] host uuid: ~p, device_uuid: ~p not activated, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags])
end end
end; end;

View File

@ -18,9 +18,9 @@ route_uuid(RouterUUID, Fields, Timestamp) when is_binary(RouterUUID), is_list(Fi
%% %%
case redis_client:hget(RouterUUID, <<"location_code">>) of case redis_client:hget(RouterUUID, <<"location_code">>) of
{ok, undefined} -> {ok, undefined} ->
lager:debug("[iot_host] the north_data hget location_code, uuid: ~p, not found", [RouterUUID]); lager:warning("[iot_host] the north_data hget location_code, uuid: ~p, not found", [RouterUUID]);
{ok, LocationCode} when is_binary(LocationCode) -> {ok, LocationCode} when is_binary(LocationCode) ->
iot_zd_endpoint:forward(LocationCode, Fields, Timestamp); iot_zd_endpoint:forward(LocationCode, Fields, Timestamp);
{error, Reason} -> {error, Reason} ->
lager:debug("[iot_host] the north_data hget location_code uuid: ~p, get error: ~p", [RouterUUID, Reason]) lager:warning("[iot_host] the north_data hget location_code uuid: ~p, get error: ~p", [RouterUUID, Reason])
end. end.