1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| -module(mod_logxml). -author('badlop@ono.com'). -behaviour(gen_mod). -export([ start/2, init/7, stop/1, send_packet/3, receive_packet/4 ]). -include("ejabberd.hrl"). -include("logger.hrl"). -include("jlib.hrl"). -define(PROCNAME, ejabberd_mod_logxml). start(Host, Opts) -> Logdir = gen_mod:get_opt(logdir, Opts, fun(A) -> A end, "/tmp/jabberlogs/"), ?DEBUG("EJABBERD_MOD_LOGXML Logdir: ~p", [Logdir]), Rd = gen_mod:get_opt(rotate_days, Opts, fun(A) -> A end, 1), ?DEBUG("EJABBERD_MOD_LOGXML Rd: ~p", [Rd]), Rf = case gen_mod:get_opt(rotate_megs, Opts, fun(A) -> A end, 10) of no -> no; Rf1 -> Rf1 * 1024 * 1024 end, ?DEBUG("EJABBERD_MOD_LOGXML Rf: ~p", [Rf]), Rp = case gen_mod:get_opt(rotate_kpackets, Opts, fun(A) -> A end, 10) of no -> no; Rp1 -> Rp1 * 1000 end, ?DEBUG("EJABBERD_MOD_LOGXML Rp: ~p", [Rp]), RotateO = {Rd, Rf, Rp}, CheckRKP = gen_mod:get_opt(check_rotate_kpackets, Opts, fun(A) -> A end, 1), ?DEBUG("EJABBERD_MOD_LOGXML RotateO: ~p", [RotateO]), Timezone = gen_mod:get_opt(timezone, Opts, fun(A) -> A end, local), ?DEBUG("EJABBERD_MOD_LOGXML Timezone: ~p", [Timezone]), Orientation = gen_mod:get_opt(orientation, Opts, fun(A) -> A end, [send, recv]), ?DEBUG("EJABBERD_MOD_LOGXML Orientation: ~p", [Orientation]), Stanza = gen_mod:get_opt(stanza, Opts, fun(A) -> A end, [iq, message, presence, other]), ?DEBUG("EJABBERD_MOD_LOGXML Stanza: ~p", [Stanza]), Direction = gen_mod:get_opt(direction, Opts, fun(A) -> A end, [internal, vhosts, external]), ?DEBUG("EJABBERD_MOD_LOGXML Direction: ~p", [Direction]), FilterO = { {orientation, Orientation}, {stanza, Stanza}, {direction, Direction}}, ShowIP = gen_mod:get_opt(show_ip, Opts, fun(A) -> A end, false), ?DEBUG("EJABBERD_MOD_LOGXML ShowIP: ~p", [ShowIP]), ejabberd_hooks:add(user_send_packet, Host, ?MODULE, send_packet, 90), ejabberd_hooks:add(user_receive_packet, Host, ?MODULE, receive_packet, 90), register( gen_mod:get_module_proc(Host, ?PROCNAME), spawn(?MODULE, init, [Host, Logdir, RotateO, CheckRKP, Timezone, ShowIP, FilterO]) ). ... ... ... 省略
|