From 9a6464aa311c5c9123fc45e26b8d4e4c25e75da3 Mon Sep 17 00:00:00 2001 From: Fabio Salvini Date: Mon, 12 Jun 2017 15:02:35 +0200 Subject: [PATCH] Restart log files monitoring on boot --- apps/log_monitor/src/config.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/log_monitor/src/config.erl b/apps/log_monitor/src/config.erl index fdf64d3..490b30d 100644 --- a/apps/log_monitor/src/config.erl +++ b/apps/log_monitor/src/config.erl @@ -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]) ->