diff --git a/apps/emqx/include/emqx_trace.hrl b/apps/emqx/include/emqx_trace.hrl index f273c2dbc..f3905bfdf 100644 --- a/apps/emqx/include/emqx_trace.hrl +++ b/apps/emqx/include/emqx_trace.hrl @@ -33,7 +33,7 @@ extra = #{} :: map() | '_', start_at :: integer() | undefined | '_', end_at :: integer() | undefined | '_', - formatter = plain :: plain | json | '_' + formatter = text :: text | json | '_' }). -define(SHARD, ?COMMON_SHARD). diff --git a/apps/emqx/src/emqx_trace/emqx_trace_handler.erl b/apps/emqx/src/emqx_trace/emqx_trace_handler.erl index c0172b2dc..8179f8c0a 100644 --- a/apps/emqx/src/emqx_trace/emqx_trace_handler.erl +++ b/apps/emqx/src/emqx_trace/emqx_trace_handler.erl @@ -48,7 +48,7 @@ type := clientid | topic | ip_address, filter := emqx_types:clientid() | emqx_types:topic() | emqx_trace:ip_address(), payload_encode := text | hidden | hex, - formatter => json | plain + formatter => json | text }. -define(CONFIG(_LogFile_), #{ @@ -72,7 +72,7 @@ Filter :: emqx_types:clientid() | emqx_types:topic() | string(), Level :: logger:level() | all, LogFilePath :: string(), - Formatter :: plain | json + Formatter :: text | json ) -> ok | {error, term()}. install(Name, Type, Filter, Level, LogFile, Formatter) -> Who = #{ @@ -92,7 +92,7 @@ install(Name, Type, Filter, Level, LogFile, Formatter) -> LogFilePath :: string() ) -> ok | {error, term()}. install(Name, Type, Filter, Level, LogFile) -> - install(Name, Type, Filter, Level, LogFile, plain). + install(Name, Type, Filter, Level, LogFile, text). -spec install( Type :: clientid | topic | ip_address, diff --git a/apps/emqx/test/emqx_trace_SUITE.erl b/apps/emqx/test/emqx_trace_SUITE.erl index 957a9850d..b5de0b979 100644 --- a/apps/emqx/test/emqx_trace_SUITE.erl +++ b/apps/emqx/test/emqx_trace_SUITE.erl @@ -97,7 +97,7 @@ t_base_create_delete(_Config) -> end_at => Now + 30 * 60, payload_encode => text, extra => #{}, - formatter => plain + formatter => text } ], ?assertEqual(ExpectFormat, emqx_trace:format([TraceRec])), diff --git a/apps/emqx_management/src/emqx_mgmt_api_trace.erl b/apps/emqx_management/src/emqx_mgmt_api_trace.erl index f0efe9f85..e5ccde4f2 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_trace.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_trace.erl @@ -317,10 +317,10 @@ fields(trace) -> )}, {formatter, hoconsc:mk( - hoconsc:union([plain, json]), + hoconsc:union([text, json]), #{ description => ?DESC(trace_log_formatter), - example => plain, + example => text, required => false } )} diff --git a/apps/emqx_management/src/emqx_mgmt_cli.erl b/apps/emqx_management/src/emqx_mgmt_cli.erl index 01c121e5b..32a24d9bd 100644 --- a/apps/emqx_management/src/emqx_mgmt_cli.erl +++ b/apps/emqx_management/src/emqx_mgmt_cli.erl @@ -507,14 +507,14 @@ trace(["list"]) -> ) end; trace(["stop", Operation, Filter0]) -> - case trace_type(Operation, Filter0, plain) of + case trace_type(Operation, Filter0, text) of {ok, Type, Filter, _} -> trace_off(Type, Filter); error -> trace([]) end; trace(["start", Operation, ClientId, LogFile]) -> trace(["start", Operation, ClientId, LogFile, "all"]); trace(["start", Operation, Filter0, LogFile, Level]) -> - trace(["start", Operation, Filter0, LogFile, Level, plain]); + trace(["start", Operation, Filter0, LogFile, Level, text]); trace(["start", Operation, Filter0, LogFile, Level, Formatter0]) -> case trace_type(Operation, Filter0, Formatter0) of {ok, Type, Filter, Formatter} -> @@ -533,16 +533,16 @@ trace(_) -> emqx_ctl:usage([ {"trace list", "List all traces started on local node"}, {"trace start client [] []", - "Traces for a client on local node (Formatter=plain|json)"}, + "Traces for a client on local node (Formatter=text|json)"}, {"trace stop client ", "Stop tracing for a client on local node"}, {"trace start topic [] []", - "Traces for a topic on local node (Formatter=plain|json)"}, + "Traces for a topic on local node (Formatter=text|json)"}, {"trace stop topic ", "Stop tracing for a topic on local node"}, {"trace start ip_address [] []", - "Traces for a client ip on local node (Formatter=plain|json)"}, + "Traces for a client ip on local node (Formatter=text|json)"}, {"trace stop ip_address ", "Stop tracing for a client ip on local node"}, {"trace start ruleid [] []", - "Traces for a rule ID on local node (Formatter=plain|json)"}, + "Traces for a rule ID on local node (Formatter=text|json)"}, {"trace stop ruleid ", "Stop tracing for a rule ID on local node"} ]). @@ -599,7 +599,7 @@ traces(["delete", Name]) -> traces(["start", Name, Operation, Filter]) -> traces(["start", Name, Operation, Filter, ?DEFAULT_TRACE_DURATION]); traces(["start", Name, Operation, Filter, DurationS]) -> - traces(["start", Name, Operation, Filter, DurationS, plain]); + traces(["start", Name, Operation, Filter, DurationS, text]); traces(["start", Name, Operation, Filter0, DurationS, Formatter0]) -> case trace_type(Operation, Filter0, Formatter0) of {ok, Type, Filter, Formatter} -> trace_cluster_on(Name, Type, Filter, DurationS, Formatter); @@ -609,17 +609,17 @@ traces(_) -> emqx_ctl:usage([ {"traces list", "List all cluster traces started"}, {"traces start client [] []", - "Traces for a client in cluster (Formatter=plain|json)"}, + "Traces for a client in cluster (Formatter=text|json)"}, {"traces start topic [] []", - "Traces for a topic in cluster (Formatter=plain|json)"}, + "Traces for a topic in cluster (Formatter=text|json)"}, {"traces start ruleid [] []", - "Traces for a rule ID in cluster (Formatter=plain|json)"}, + "Traces for a rule ID in cluster (Formatter=text|json)"}, {"traces start ip_address [] []", "Traces for a client IP in cluster\n" "Trace will start immediately on all nodes, including the core and replicant,\n" "and will end after seconds. The default value for is " ?DEFAULT_TRACE_DURATION - " seconds. (Formatter=plain|json)"}, + " seconds. (Formatter=text|json)"}, {"traces stop ", "Stop trace in cluster"}, {"traces delete ", "Delete trace in cluster"} ]). @@ -657,7 +657,7 @@ trace_cluster_off(Name) -> {error, Error} -> emqx_ctl:print("[error] Stop cluster_trace ~s: ~p~n", [Name, Error]) end. -trace_type(Op, Match, "plain") -> trace_type(Op, Match, plain); +trace_type(Op, Match, "text") -> trace_type(Op, Match, text); trace_type(Op, Match, "json") -> trace_type(Op, Match, json); trace_type("client", ClientId, Formatter) -> {ok, clientid, bin(ClientId), Formatter}; trace_type("topic", Topic, Formatter) -> {ok, topic, bin(Topic), Formatter}; diff --git a/rel/i18n/emqx_mgmt_api_trace.hocon b/rel/i18n/emqx_mgmt_api_trace.hocon index 3b12caf97..13d814c21 100644 --- a/rel/i18n/emqx_mgmt_api_trace.hocon +++ b/rel/i18n/emqx_mgmt_api_trace.hocon @@ -116,7 +116,7 @@ current_trace_offset.label: """Offset from the current trace position.""" trace_log_formatter.desc: -"""The formatter that will be used to format the trace log entries. Set this to plain to format the log entries as plain text (default). Set it to json to format each log entry as a JSON object.""" +"""The formatter that will be used to format the trace log entries. Set this to text to format the log entries as plain text (default). Set it to json to format each log entry as a JSON object.""" trace_log_formatter.label: """Trace Log Entry Formatter"""