From d5136c731c5714051bca932fab2d3e7820cd5784 Mon Sep 17 00:00:00 2001 From: Fabio Salvini Date: Sun, 2 Jul 2017 09:37:38 +0200 Subject: [PATCH] Log lines as list instead of binary --- TODO.md | 1 - apps/log_monitor/src/gatherer.erl | 4 ++-- apps/log_monitor/src/watcher.erl | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 83a6e44..7b8c65c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,5 @@ TODO ===== - - gatherer.erl:29 Error on ++. - Limit number of emails that can be sent in a period of time. - gen_fsm for gatherer? diff --git a/apps/log_monitor/src/gatherer.erl b/apps/log_monitor/src/gatherer.erl index 6501b62..795f4de 100644 --- a/apps/log_monitor/src/gatherer.erl +++ b/apps/log_monitor/src/gatherer.erl @@ -26,9 +26,9 @@ handle_info({log_line, Text}, [on, Log = #log{error_regex = ErrorRegex}, Error, true -> timer:cancel(Timer), {ok, NewTimer} = timer:send_after(1000, {timeout}), - {noreply, [on, Log, Error ++ "\n" ++ Text, NewTimer, SafeTimer]}; + {noreply, [on, Log, Error ++ Text, NewTimer, SafeTimer]}; false -> - {noreply, [on, Log, Error ++ "\n" ++ Text, Timer, SafeTimer]} + {noreply, [on, Log, Error ++ Text, Timer, SafeTimer]} end; handle_info({timeout}, [on, Log = #log{file = File}, Error, Timer, SafeTimer]) -> timer:cancel(Timer), diff --git a/apps/log_monitor/src/watcher.erl b/apps/log_monitor/src/watcher.erl index a7af2c9..e50bb09 100644 --- a/apps/log_monitor/src/watcher.erl +++ b/apps/log_monitor/src/watcher.erl @@ -19,7 +19,7 @@ handle_info(Msg, [File, SupPid, Port]) -> case Msg of {Port, {data, Text}} -> GathererPid = gatherer_pid(SupPid), - GathererPid ! {log_line, Text}, + GathererPid ! {log_line, binary_to_list(Text)}, {noreply, [File, SupPid, Port]}; {Port, {exit_status, _Status}} -> {stop, tail_exit, [File]}