mod_service_log - logging received messages ?

hi,
i would like to write a small component which logs all sent and received messages into a postgresql database ..
i thought with mod_service_log it would be quite easy to accomplish .. but i'm only receiving messages sent from the jabber users on my server..
i don't receive messages which are received by them ..

is it possible to configure mod_service_log to also transmit received messages ?

i guess if i had a clue about rebol i could just modify mod_logxml to store the messages in a database.. but.. i haven't .. and .. i would like to have
the messages real time in my database, and not parse the .xml file in a cronjob ...

thanks,
Herbert Poul
http://goim.us

... altough it seams quite

... altough it seams quite odd .. since the source code of mod_service_log is:

start(Host, _Opts) ->
ejabberd_hooks:add(user_send_packet, Host,
?MODULE, log_user_send, 50),
ejabberd_hooks:add(user_receive_packet, Host,
?MODULE, log_user_receive, 50),
ok.

log_user_send(From, To, Packet) ->
log_packet(From, To, Packet).

log_user_receive(_JID, From, To, Packet) ->
log_packet(From, To, Packet).

i have no idea about rebol .. nor about ejabberd's inner workings.. but if i understand it correctly .. it registers a hook for send and receive.. and handles them the same way ..

but i'm 100% certain i'm only receiving packets which were sent by users of the server. not one packet which was receceived by a user on my ejabberd server was transmitted to my small test component (neither to bandersnatch which i tried before)

any ideas ?

Doesn't Bandersnatch store

Doesn't Bandersnatch store all messages on a database?

Re: Doesn't Bandersnatch store

badlop wrote:

Doesn't Bandersnatch store all messages on a database?

well .. it uses the same module (mod_service_log) .. and the module seams to transmit only packets sent by users on the server.. not received by them ..
that's the problem ....

(as i said in the later post .. i've tried bandersnatch before... actually i wondered why it would only store sent packets .. so i made a small 5 line component in perl which outputs everything it receives.. and.. packets received by users on the servers aren't transmitted to the component ....)

Re: mod_service_log - logging received messages ?

kahless@sphene.net wrote:
i thought with mod_service_log it would be quite easy to accomplish .. but i'm only receiving messages sent from the jabber users on my server.. i don't receive messages which are received by them

It seems a bug or misfeature in mod_service_log, reported on Bugzilla Bug 215 - mod_service_log logs only local messages. There you will find a patch that hopefully fixes the problem.

thanks a lot .. one small

thanks a lot .. one small thing though .. do you think it would be possible to add a attribute or something to the XML which is sent by mod_service_log containing if the packet was received or sent ?

this would make it a lot easier to prevent duplicated log entries because sender and receiver are on the same server.. which triggers two events ..

Re: thanks a lot .. one small

kahless@sphene.net wrote:

do you think it would be possible to add a attribute or something to the XML which is sent by mod_service_log containing if the packet was received or sent ?

It's possible, if you think that helps you. However, since I don't see this too much important, I won't submit it for inclusion on ejabberd.

Here is the patch:

--- mod_service_log.erl (revisión: 507)
+++ mod_service_log.erl (copia de trabajo)
@@ -34,13 +34,13 @@
     ok.

 log_user_send(From, To, Packet) ->
-    log_packet(From, To, Packet, From#jid.lserver).
+    log_packet(From, To, Packet, From#jid.lserver, "send").

 log_user_receive(_JID, From, To, Packet) ->
-    log_packet(From, To, Packet, To#jid.lserver).
+    log_packet(From, To, Packet, To#jid.lserver, "recv").


-log_packet(From, To, {xmlelement, Name, Attrs, Els}, Host) ->
+log_packet(From, To, {xmlelement, Name, Attrs, Els}, Host, Direction) ->
     Loggers = gen_mod:get_module_opt(Host, ?MODULE, loggers, []),
     ServerJID = #jid{user = "", server = Host, resource = "",
                     luser = "", lserver = Host, lresource = ""},
@@ -54,6 +54,6 @@
                ServerJID,
                #jid{user = "", server = Logger, resource = "",
                     luser = "", lserver = Logger, lresource = ""},
-               {xmlelement, "route", [], [FixedPacket]})
+               {xmlelement, "route", [{"direction", Direction}], [FixedPacket]})
       end, Loggers).

With this patch, packets look like this:

<route from='atenea' to='log.atenea' direction='send'>
  <iq from='badlop@atenea/Tka' to='atenea' id='16' type='get' xml:lang='es'>
  ...
</route>

Re: thanks a lot .. one small

badlop wrote:

I won't submit it for inclusion on ejabberd.

thx..

imo it is important, because otherwise i would receive 2 completely identical packets, altough only one message/iq/whatever was sent by a user...
and it would be harder to prevent duplicate log entries..

with the 'direction' information the only thing i need to do if i get two identical packets is to see if one is 'send' while the other is 'receive' and i can be sure that i can safely ignore one of them.

without the 'direction' i would have to parse the JID to see if both are local users and just assume that i can ignore one of the two matching packets.

... but anyway .. just my thoughts :)
thx again
Herbert Poul
http://goim.us

hi ! does your component is

hi !
does your component is available in public domain ?

Syndicate content