Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

don't use priv dir for logs of any kind #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ dcos.pem
logs/
erl_crash.dump
rebar3.crashdump
dump.rdb
dump.rdb
logs
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ shell:
plots:
pkill -9 beam.smp; \
clear; \
rm -rf priv/lager/ priv/evaluation; \
rm -rf logs/lager/ logs/evaluation; \
(cd priv/ && git clone https://github.com/lasp-lang/evaluation); \
./rebar3 ct --readable=false --suite=test/lasp_peer_to_peer_advertisement_counter_SUITE; \
./rebar3 ct --readable=false --suite=test/lasp_client_server_advertisement_counter_SUITE; \
Expand All @@ -147,10 +147,10 @@ part-div:
./rebar3 ct --readable=false --suite=test/lasp_advertisement_counter_partition_overcounting_SUITE

tail-logs:
tail -F priv/lager/*/*/log/*.log
tail -F logs/lager/*/*/log/*.log

logs:
cat priv/lager/*/*/log/*.log
cat logs/lager/*/*/log/*.log

DIALYZER_APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto

Expand Down
4 changes: 2 additions & 2 deletions simulations/lasp_gui_resource.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ content_types_provided(Req, Ctx) ->
%% return file path
-spec file_path(wrq:reqdata() | list()) -> string().
file_path(Path) when is_list(Path) ->
filename:join([code:priv_dir(?APP)] ++ [Path]);
filename:join([code:lib_dir(?APP)] ++ [Path]);
file_path(Req) ->
Path=wrq:path_tokens(Req),
filename:join([code:priv_dir(?APP)] ++ Path).
filename:join([code:lib_dir(?APP)] ++ Path).

%% loads a resource file from disk and returns it
-spec get_file(wrq:reqdata()) -> binary().
Expand Down
2 changes: 1 addition & 1 deletion simulations/lasp_instrumentation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ start_transmission_timer() ->

%% @private
root_eval_dir() ->
code:priv_dir(?APP) ++ "/evaluation".
code:lib_dir(?APP) ++ "/evaluation".

%% @private
root_log_dir() ->
Expand Down
2 changes: 1 addition & 1 deletion simulations/lasp_logs_resource.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ content_types_provided(Req, Ctx) ->
{[{"application/json", to_json}], Req, Ctx}.

to_json(ReqData, State) ->
Filenames = filelib:wildcard("*.csv", code:priv_dir(?APP) ++ "/logs"),
Filenames = filelib:wildcard("*.csv", code:lib_dir(?APP) ++ "/logs"),
Filenames1 = [list_to_binary(Filename) || Filename <- Filenames],
Encoded = jsx:encode(#{logs => Filenames1}),
{Encoded, ReqData, State}.
2 changes: 1 addition & 1 deletion simulations/lasp_plots_resource.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ content_types_provided(Req, Ctx) ->
{[{"application/json", to_json}], Req, Ctx}.

to_json(ReqData, State) ->
Filenames = filelib:wildcard("*.pdf", code:priv_dir(?APP) ++ "/plots"),
Filenames = filelib:wildcard("*.pdf", code:lib_dir(?APP) ++ "/plots"),
Filenames1 = [list_to_binary(Filename) || Filename <- Filenames],
Encoded = jsx:encode(#{plots => Filenames1}),
{Encoded, ReqData, State}.
4 changes: 2 additions & 2 deletions simulations/lasp_simulation_support.erl
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ start(Case, _Config, Options) ->
LoaderFun = fun(Node) ->
ct:pal("Loading lasp on node: ~p", [Node]),

PrivDir = code:priv_dir(?APP),
NodeDir = filename:join([PrivDir, "lager", Case, Node]),
LibDir = code:lib_dir(?APP),
NodeDir = filename:join([LibDir, "logs", "lager", Case, Node]),

%% Manually force sasl loading, and disable the logger.
ok = rpc:call(Node, application, load, [sasl]),
Expand Down
2 changes: 1 addition & 1 deletion src/lasp_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ web_config() ->
Config = [
{ip, Ip},
{port, Port},
{log_dir, "priv/log"},
{log_dir, "logs"},
{dispatch, dispatch()}
],
Node = lasp_support:mynode(),
Expand Down
6 changes: 3 additions & 3 deletions src/lasp_support.erl
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ join_to(N, RunnerNode) ->
load_lasp(Node, _Config, Case) ->
ct:pal("Loading applications on node: ~p", [Node]),

PrivDir = code:priv_dir(?APP),
NodeDir = filename:join([PrivDir, "lager", Case, Node]),
LibDir = code:lib_dir(?APP),
NodeDir = filename:join([LibDir, "logs", "lager", Case, Node]),

%% Manually force sasl loading, and disable the logger.
ok = rpc:call(Node, application, load, [sasl]),
Expand Down Expand Up @@ -451,4 +451,4 @@ push_logs() ->

%% @doc Return node name.
mynode() ->
partisan_peer_service_manager:mynode().
partisan_peer_service_manager:mynode().
2 changes: 1 addition & 1 deletion test/lasp_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ sql_run_case(Iterations, Acc, From, To, Row, Threshold0) ->
sql_run_case(Iterations - 1, [Time | Acc], From, To, Row, NewThreshold).

write_csv(Dir, Option, Cases, Trim) ->
Path = code:priv_dir(lasp)
Path = code:lib_dir(lasp)
++ "/evaluation/logs/"
++ atom_to_list(Dir) ++ "/"
++ atom_to_list(Option) ++ "/"
Expand Down