From 1fab8084e1226acc1cefa475be3bbd52cd2dfb86 Mon Sep 17 00:00:00 2001 From: Feng Date: Thu, 1 Oct 2015 11:23:37 +0800 Subject: [PATCH] rm cli --- src/emqttd_trace.erl | 49 -------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/src/emqttd_trace.erl b/src/emqttd_trace.erl index c79bdcbae..8edcebad0 100644 --- a/src/emqttd_trace.erl +++ b/src/emqttd_trace.erl @@ -29,11 +29,6 @@ -author("Feng Lee "). --include("emqttd_cli.hrl"). - -%% CLI --export([cli/1]). - %% API Function Exports -export([start_link/0]). @@ -51,48 +46,6 @@ -define(TRACE_OPTIONS, [{formatter_config, [time, " [",severity,"] ", message, "\n"]}]). - -%%%============================================================================= -%%% CLI -%%%============================================================================= - -cli(["list"]) -> - lists:foreach(fun({{Who, Name}, LogFile}) -> - ?PRINT("trace ~s ~s -> ~s~n", [Who, Name, LogFile]) - end, all_traces()); - -cli(["client", ClientId, "off"]) -> - cli(trace_off, client, ClientId); -cli(["client", ClientId, LogFile]) -> - cli(trace_on, client, ClientId, LogFile); -cli(["topic", Topic, "off"]) -> - cli(trace_off, topic, Topic); -cli(["topic", Topic, LogFile]) -> - cli(trace_on, topic, Topic, LogFile); - -cli(_) -> - ?PRINT_CMD("trace list", "#query all traces"), - ?PRINT_CMD("trace client ","#trace client with ClientId"), - ?PRINT_CMD("trace client off", "#stop to trace client"), - ?PRINT_CMD("trace topic ", "#trace topic with Topic"), - ?PRINT_CMD("trace topic off", "#stop to trace Topic"). - -cli(trace_on, Who, Name, LogFile) -> - case start_trace({Who, list_to_binary(Name)}, LogFile) of - ok -> - ?PRINT("trace ~s ~s successfully.~n", [Who, Name]); - {error, Error} -> - ?PRINT("trace ~s ~s error: ~p~n", [Who, Name, Error]) - end. - -cli(trace_off, Who, Name) -> - case stop_trace({Who, list_to_binary(Name)}) of - ok -> - ?PRINT("stop to trace ~s ~s successfully.~n", [Who, Name]); - {error, Error} -> - ?PRINT("stop to trace ~s ~s error: ~p.~n", [Who, Name, Error]) - end. - %%%============================================================================= %%% API %%%============================================================================= @@ -133,7 +86,6 @@ all_traces() -> gen_server:call(?MODULE, all_traces). init([]) -> - emqttd_ctl:register_cmd(trace, {?MODULE, cli}, []), {ok, #state{level = info, trace_map = #{}}}. handle_call({start_trace, Who, LogFile}, _From, State = #state{level = Level, trace_map = TraceMap}) -> @@ -171,7 +123,6 @@ handle_info(_Info, State) -> {noreply, State}. terminate(_Reason, _State) -> - emqttd_ctl:unregister_cmd(trace), ok. code_change(_OldVsn, State, _Extra) ->