fix service
This commit is contained in:
parent
d9d8e6b53c
commit
18723bdb0d
@ -48,9 +48,13 @@ start_link(FileName) when is_list(FileName) ->
|
||||
{stop, Reason :: term()} | ignore).
|
||||
init([FileName]) ->
|
||||
ensure_dir(filename:dirname(FileName)),
|
||||
{ok, IoDevice} = file:open(FileName, [append, binary]),
|
||||
|
||||
{ok, #state{file = IoDevice, file_name = FileName}}.
|
||||
case file:open(FileName, [append, binary]) of
|
||||
{ok, IoDevice} ->
|
||||
{ok, #state{file = IoDevice, file_name = FileName}};
|
||||
{error, Reason} ->
|
||||
lager:warning("[modbus_logger] create log file: ~p, error: ~p", [FileName, Reason]),
|
||||
ignore
|
||||
end.
|
||||
|
||||
%% @private
|
||||
%% @doc Handling call messages
|
||||
|
||||
@ -241,5 +241,9 @@ retry_connect() ->
|
||||
create_log_file(undefined) ->
|
||||
undefined;
|
||||
create_log_file(FileName) ->
|
||||
{ok, FilePid} = modbus_logger:start_link(FileName),
|
||||
FilePid.
|
||||
case modbus_logger:start_link(FileName) of
|
||||
{ok, FilePid} ->
|
||||
FilePid;
|
||||
_ ->
|
||||
undefined
|
||||
end.
|
||||
Loading…
x
Reference in New Issue
Block a user