fix: check if trace is enabled when the file is not found
This commit is contained in:
parent
683bec16a3
commit
2740c80b20
|
@ -145,6 +145,8 @@ stream_log_file(#{name := Name}, Params) ->
|
||||||
{eof, Size} ->
|
{eof, Size} ->
|
||||||
Meta = #{<<"position">> => Size, <<"bytes">> => Bytes},
|
Meta = #{<<"position">> => Size, <<"bytes">> => Bytes},
|
||||||
{ok, #{meta => Meta, items => <<"">>}};
|
{ok, #{meta => Meta, items => <<"">>}};
|
||||||
|
{error, trace_disabled} ->
|
||||||
|
{error, io_lib:format("trace_disable_on_~s", [Node0])};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
logger:log(error, "read_file_failed ~p", [{Node, Name, Reason, Position, Bytes}]),
|
logger:log(error, "read_file_failed ~p", [{Node, Name, Reason, Position, Bytes}]),
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
|
@ -194,6 +196,11 @@ read_file(Path, Offset, Bytes) ->
|
||||||
after
|
after
|
||||||
file:close(IoDevice)
|
file:close(IoDevice)
|
||||||
end;
|
end;
|
||||||
|
{error, enoent} ->
|
||||||
|
case emqx_trace:is_enable() of
|
||||||
|
false -> {error, trace_disabled};
|
||||||
|
true -> {error, enoent}
|
||||||
|
end;
|
||||||
{error, Reason} -> {error, Reason}
|
{error, Reason} -> {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue