From 04d2234e0a28cf006acb271dc797e1f5a7828566 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sun, 1 May 2016 21:35:23 +0200 Subject: [PATCH] mod_message_log: Add mod_opt_type/1 callback --- mod_message_log/src/mod_message_log.erl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mod_message_log/src/mod_message_log.erl b/mod_message_log/src/mod_message_log.erl index 9fda944..9245202 100644 --- a/mod_message_log/src/mod_message_log.erl +++ b/mod_message_log/src/mod_message_log.erl @@ -14,7 +14,8 @@ %% gen_mod/supervisor callbacks. -export([start_link/1, start/2, - stop/1]). + stop/1, + mod_opt_type/1]). %% gen_server callbacks. -export([init/1, @@ -87,6 +88,13 @@ stop(Host) -> ok % We just run one process per node. 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. %% ------------------------------------------------------------------- @@ -96,7 +104,7 @@ stop(Host) -> init(Opts) -> process_flag(trap_exit, true), 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), {ok, IoDevice} = file:open(Filename, ?FILE_MODES), {ok, #state{filename = Filename, iodevice = IoDevice}}.