aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src
diff options
context:
space:
mode:
authorPiotr Dorobisz <[email protected]>2011-03-09 12:59:56 +0100
committerHenrik Nord <[email protected]>2011-08-30 15:22:17 +0200
commit034b105741df4e6d740ad1ec4b97df569eb2a6ca (patch)
tree0d5c1001072660f4a7baf9bae95ce0b36a4b94b4 /lib/observer/src
parent7611776d25dc13d8df13660e21c5b3c093e2b8c6 (diff)
downloadotp-034b105741df4e6d740ad1ec4b97df569eb2a6ca.tar.gz
otp-034b105741df4e6d740ad1ec4b97df569eb2a6ca.tar.bz2
otp-034b105741df4e6d740ad1ec4b97df569eb2a6ca.zip
Allow to specify fetch directory
Diffstat (limited to 'lib/observer/src')
-rw-r--r--lib/observer/src/ttb.erl24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/observer/src/ttb.erl b/lib/observer/src/ttb.erl
index 45cca218c4..1a34e5b2fc 100644
--- a/lib/observer/src/ttb.erl
+++ b/lib/observer/src/ttb.erl
@@ -510,18 +510,29 @@ stop(Opts) ->
stop([Opts]).
stop_opts(Opts) ->
+ FetchDir = proplists:get_value(fetch_dir, Opts),
+ ensure_fetch_dir(FetchDir),
case {lists:member(format,Opts), lists:member(return, Opts)} of
{true, _} ->
- format; % format implies fetch
+ {format, FetchDir}; % format implies fetch
{_, true} ->
- fetch; % if we specify return, the data should be fetched
+ {fetch, FetchDir}; % if we specify return, the data should be fetched
_ ->
case lists:member(fetch,Opts) of
- true -> fetch;
+ true -> {fetch, FetchDir};
false -> nofetch
end
end.
+ensure_fetch_dir(undefined) -> ok;
+ensure_fetch_dir(Dir) ->
+ case filelib:is_file(Dir) of
+ true ->
+ throw({error, exists, Dir});
+ false ->
+ ok
+ end.
+
stop_return(R,Opts) ->
case {lists:member(return,Opts),R} of
{true,_} ->
@@ -592,9 +603,9 @@ loop(NodeInfo) ->
dbg:stop_clear(),
ets:delete(?history_table),
Sender ! {?MODULE,stopped};
- {stop,FetchOrFormat,Sender} ->
+ {stop,{FetchOrFormat, UserDir} ,Sender} ->
Localhost = host(node()),
- Dir = ?upload_dir++ts(),
+ Dir = get_fetch_dir(UserDir),
file:make_dir(Dir),
%% The nodes are traversed twice here because
%% the meta tracing in observer_backend must be
@@ -629,6 +640,9 @@ loop(NodeInfo) ->
?get_status
end.
+get_fetch_dir(undefined) -> ?upload_dir ++ ts();
+get_fetch_dir(Dir) -> Dir.
+
get_nodes() ->
?MODULE ! {get_nodes,self()},
receive {?MODULE,Nodes} -> Nodes end.