Merge pull request #27 from weiss/fix-s2s-log
Fix mod_s2s_log to work with ejabberd 13.12
This commit is contained in:
		
						commit
						ea1025879d
					
				| @ -44,19 +44,18 @@ | |||||||
| -include("ejabberd.hrl"). | -include("ejabberd.hrl"). | ||||||
| 
 | 
 | ||||||
| -define(PROCNAME, ?MODULE). | -define(PROCNAME, ?MODULE). | ||||||
| -define(DEFAULT_FILENAME, "s2s.log"). | -define(DEFAULT_FILENAME, <<"s2s.log">>). | ||||||
| -define(FILE_OPTS, [append,raw]). | -define(FILE_OPTS, [append,raw]). | ||||||
| 
 | 
 | ||||||
| -record(config, {filename=?DEFAULT_FILENAME, iodevice}). | -record(config, {filename=?DEFAULT_FILENAME, iodevice}). | ||||||
| 
 | 
 | ||||||
| %% For now we only support one log file for all vhosts. | %% For now we only support one log file for all vhosts. | ||||||
| start(Host, Opts) -> | start(_Host, Opts) -> | ||||||
|     %% ejabberd starts modules sequentially so we assume no race |     %% ejabberd starts modules sequentially so we assume no race | ||||||
|     %% condition is possible here |     %% condition is possible here | ||||||
|     case whereis(?PROCNAME) of |     case whereis(?PROCNAME) of | ||||||
| 	undefined -> | 	undefined -> | ||||||
| 	    ?DEBUG("Starting mod_s2s_log ~p  ~p~n", [Host, Opts]), | 	    Filename = gen_mod:get_opt(filename, Opts, fun(V) -> V end, ?DEFAULT_FILENAME), | ||||||
| 	    Filename = gen_mod:get_opt(filename, Opts, ?DEFAULT_FILENAME), |  | ||||||
| 	    %% TODO: Both hooks will need Host parameter for vhost support | 	    %% TODO: Both hooks will need Host parameter for vhost support | ||||||
| 	    ejabberd_hooks:add(reopen_log_hook, ?MODULE, reopen_log, 55), | 	    ejabberd_hooks:add(reopen_log_hook, ?MODULE, reopen_log, 55), | ||||||
| 	    ejabberd_hooks:add(s2s_connect_hook, ?MODULE, s2s_connect, 55), | 	    ejabberd_hooks:add(s2s_connect_hook, ?MODULE, s2s_connect, 55), | ||||||
| @ -67,7 +66,6 @@ start(Host, Opts) -> | |||||||
|     end. |     end. | ||||||
| 
 | 
 | ||||||
| init(Config)-> | init(Config)-> | ||||||
|     ?DEBUG("Starting mod_s2s_log ~p with config ~p~n", [?MODULE, Config]), |  | ||||||
|     {ok, IOD} = file:open(Config#config.filename, ?FILE_OPTS), |     {ok, IOD} = file:open(Config#config.filename, ?FILE_OPTS), | ||||||
|     loop(Config#config{iodevice=IOD}). |     loop(Config#config{iodevice=IOD}). | ||||||
| 
 | 
 | ||||||
| @ -79,7 +77,6 @@ loop(Config) -> | |||||||
| 	{reopen_log} -> | 	{reopen_log} -> | ||||||
| 	    file:close(Config#config.iodevice), | 	    file:close(Config#config.iodevice), | ||||||
| 	    {ok, IOD} = file:open(Config#config.filename, ?FILE_OPTS), | 	    {ok, IOD} = file:open(Config#config.filename, ?FILE_OPTS), | ||||||
| 	    ?INFO_MSG("Reopened s2s log file", []), |  | ||||||
| 	    loop(Config#config{iodevice = IOD}); | 	    loop(Config#config{iodevice = IOD}); | ||||||
| 	stop -> | 	stop -> | ||||||
| 	    file:close(Config#config.iodevice), | 	    file:close(Config#config.iodevice), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user