Restart log files monitoring on boot

This commit is contained in:
Fabio Salvini 2017-06-12 15:02:35 +02:00
parent bbf2a4ff54
commit 9a6464aa31

View File

@ -13,9 +13,12 @@ start_link() ->
init([]) ->
register(config, self()),
{ok, Storage} = application:get_env(log_monitor, storage),
{ok, Logfiles} = dets:open_file(Storage, []),
{ok, Logfiles} = dets:open_file(Storage, [{auto_save, 1000}]),
Statuses = ets:new(log_statuses, []),
%% TODO: start logs inside Logfile
lists:foreach(fun({File, ErrorRegex}) ->
ets:insert(Statuses, {File, disabled}),
logfiles_sup:add_child([File, ErrorRegex])
end, dets:foldl(fun(X, L) -> [X|L] end, [], Logfiles)),
{ok, [Logfiles, Statuses]}.
handle_info({watcher_init, File}, State = [_Logfiles, Statuses]) ->