mod_message_log: Add mod_opt_type/1 callback
This commit is contained in:
parent
7429577b7a
commit
04d2234e0a
|
@ -14,7 +14,8 @@
|
||||||
%% gen_mod/supervisor callbacks.
|
%% gen_mod/supervisor callbacks.
|
||||||
-export([start_link/1,
|
-export([start_link/1,
|
||||||
start/2,
|
start/2,
|
||||||
stop/1]).
|
stop/1,
|
||||||
|
mod_opt_type/1]).
|
||||||
|
|
||||||
%% gen_server callbacks.
|
%% gen_server callbacks.
|
||||||
-export([init/1,
|
-export([init/1,
|
||||||
|
@ -87,6 +88,13 @@ stop(Host) ->
|
||||||
ok % We just run one process per node.
|
ok % We just run one process per node.
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec mod_opt_type(atom()) -> fun((term()) -> term()) | [atom()].
|
||||||
|
|
||||||
|
mod_opt_type(filename) ->
|
||||||
|
fun iolist_to_binary/1;
|
||||||
|
mod_opt_type(_) ->
|
||||||
|
[filename].
|
||||||
|
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
%% gen_server callbacks.
|
%% gen_server callbacks.
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
|
@ -96,7 +104,7 @@ stop(Host) ->
|
||||||
init(Opts) ->
|
init(Opts) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
ejabberd_hooks:add(reopen_log_hook, ?MODULE, reopen_log, 42),
|
ejabberd_hooks:add(reopen_log_hook, ?MODULE, reopen_log, 42),
|
||||||
Filename = gen_mod:get_opt(filename, Opts, fun(V) -> V end,
|
Filename = gen_mod:get_opt(filename, Opts, fun iolist_to_binary/1,
|
||||||
?DEFAULT_FILENAME),
|
?DEFAULT_FILENAME),
|
||||||
{ok, IoDevice} = file:open(Filename, ?FILE_MODES),
|
{ok, IoDevice} = file:open(Filename, ?FILE_MODES),
|
||||||
{ok, #state{filename = Filename, iodevice = IoDevice}}.
|
{ok, #state{filename = Filename, iodevice = IoDevice}}.
|
||||||
|
|
Loading…
Reference in New Issue