erlang - change trace log format in emqtt message broker -


i using emqtt message broker mqtt. not erlang developer , has 0 knowledge on that. have used erlang based broker, because after searching many open source broker online , suggestions people advantage of erlang based server.

now kind of stuck out put of emqttd_cli trace command. not json type , if use perl parser convert json type getting delayed output.

i want know, in file change trace log output format.

i looked on trace code of broker , found file src/emqttd_protocol.erl. exported function named trace/3 has code need.

second argument of function, named packet, has information of receive & send data via broker. can fetch required data , format according how want print.

edit : sample modified code added

trace(recv, packet, protostate) ->      packetheader = packet#mqtt_packet.header,     hostinfo = esockd_net:format(protostate#proto_state.peername),      %% packetinfo = {clientid, username, clientip, clientport, payload, qos, retain}     packetinfo = {protostate#proto_state.client_id, protostate#proto_state.username, lists:nth(1, hostinfo), lists:nth(3, hostinfo), packet#mqtt_packet.payload, packetheader#mqtt_packet_header.qos, packetheader#mqtt_packet_header.retain},      ?log(info, "data received ~s", [packetinfo], protostate); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -