Fix copyright and unify log method
This commit is contained in:
parent
9dbc34c376
commit
911a813891
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -39,3 +39,5 @@
|
||||||
begin
|
begin
|
||||||
(logger:log(Level,#{},#{report_cb => fun(_) -> {(Format), (Args)} end}))
|
(logger:log(Level,#{},#{report_cb => fun(_) -> {(Format), (Args)} end}))
|
||||||
end).
|
end).
|
||||||
|
|
||||||
|
-define(LOG(Level, Format), ?LOG(Level, Format, [])).
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%%
|
%%
|
||||||
%% %CopyrightBegin%
|
%% %CopyrightBegin%
|
||||||
%%
|
%%
|
||||||
%% Copyright Ericsson AB 2017-2013-2019. All Rights Reserved.
|
%% Copyright Ericsson AB 2013-2019. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -54,7 +54,7 @@ start(Module, Config) ->
|
||||||
{ok, Ref, Conn};
|
{ok, Ref, Conn};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
Config1 = obfuscate(Config),
|
Config1 = obfuscate(Config),
|
||||||
?ERROR("Failed to connect with module=~p\n"
|
?LOG(error, "Failed to connect with module=~p\n"
|
||||||
"config=~p\nreason:~p", [Module, Config1, Reason]),
|
"config=~p\nreason:~p", [Module, Config1, Reason]),
|
||||||
error
|
error
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2013-2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -28,4 +28,3 @@ multicall(Nodes, Mod, Fun, Args) ->
|
||||||
|
|
||||||
cast(Node, Mod, Fun, Args) ->
|
cast(Node, Mod, Fun, Args) ->
|
||||||
?RPC:cast(Node, Mod, Fun, Args).
|
?RPC:cast(Node, Mod, Fun, Args).
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
-type(pubsub() :: publish | subscribe).
|
-type(pubsub() :: publish | subscribe).
|
||||||
-type(topic() :: binary()).
|
-type(topic() :: binary()).
|
||||||
-type(subid() :: binary() | atom()).
|
-type(subid() :: binary() | atom()).
|
||||||
-type(subopts() :: #{qos := eqmx_mqtt_types:qos(),
|
-type(subopts() :: #{qos := emqx_mqtt_types:qos(),
|
||||||
share => binary(),
|
share => binary(),
|
||||||
atom() => term()
|
atom() => term()
|
||||||
}).
|
}).
|
||||||
|
@ -59,4 +59,3 @@
|
||||||
-type(alarm() :: #alarm{}).
|
-type(alarm() :: #alarm{}).
|
||||||
-type(plugin() :: #plugin{}).
|
-type(plugin() :: #plugin{}).
|
||||||
-type(command() :: #command{}).
|
-type(command() :: #command{}).
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ standing_by(state_timeout, do_connect, State) ->
|
||||||
standing_by({call, From}, _Call, _State) ->
|
standing_by({call, From}, _Call, _State) ->
|
||||||
{keep_state_and_data, [{reply, From, {error,standing_by}}]};
|
{keep_state_and_data, [{reply, From, {error,standing_by}}]};
|
||||||
standing_by(info, Info, State) ->
|
standing_by(info, Info, State) ->
|
||||||
?INFO("Portal ~p discarded info event at state standing_by:\n~p", [name(), Info]),
|
?LOG(info, "Portal ~p discarded info event at state standing_by:\n~p", [name(), Info]),
|
||||||
{keep_state_and_data, State};
|
{keep_state_and_data, State};
|
||||||
standing_by(Type, Content, State) ->
|
standing_by(Type, Content, State) ->
|
||||||
common(standing_by, Type, Content, State).
|
common(standing_by, Type, Content, State).
|
||||||
|
@ -298,7 +298,7 @@ connecting(enter, _, #{reconnect_delay_ms := Timeout,
|
||||||
ok = subscribe_local_topics(Forwards),
|
ok = subscribe_local_topics(Forwards),
|
||||||
case ConnectFun(Subs) of
|
case ConnectFun(Subs) of
|
||||||
{ok, ConnRef, Conn} ->
|
{ok, ConnRef, Conn} ->
|
||||||
?INFO("Portal ~p connected", [name()]),
|
?LOG(info, "Portal ~p connected", [name()]),
|
||||||
Action = {state_timeout, 0, connected},
|
Action = {state_timeout, 0, connected},
|
||||||
{keep_state, State#{conn_ref => ConnRef, connection => Conn}, Action};
|
{keep_state, State#{conn_ref => ConnRef, connection => Conn}, Action};
|
||||||
error ->
|
error ->
|
||||||
|
@ -348,7 +348,7 @@ connected(info, {disconnected, ConnRef, Reason},
|
||||||
#{conn_ref := ConnRefCurrent, connection := Conn} = State) ->
|
#{conn_ref := ConnRefCurrent, connection := Conn} = State) ->
|
||||||
case ConnRefCurrent =:= ConnRef of
|
case ConnRefCurrent =:= ConnRef of
|
||||||
true ->
|
true ->
|
||||||
?INFO("Portal ~p diconnected~nreason=~p", [name(), Conn, Reason]),
|
?LOG(info, "Portal ~p diconnected~nreason=~p", [name(), Conn, Reason]),
|
||||||
{next_state, connecting,
|
{next_state, connecting,
|
||||||
State#{conn_ref := undefined, connection := undefined}};
|
State#{conn_ref := undefined, connection := undefined}};
|
||||||
false ->
|
false ->
|
||||||
|
@ -360,7 +360,7 @@ connected(info, {batch_ack, Ref}, State) ->
|
||||||
keep_state_and_data;
|
keep_state_and_data;
|
||||||
bad_order ->
|
bad_order ->
|
||||||
%% try re-connect then re-send
|
%% try re-connect then re-send
|
||||||
?ERROR("Bad order ack received by portal ~p", [name()]),
|
?LOG(error, "Bad order ack received by portal ~p", [name()]),
|
||||||
{next_state, connecting, disconnect(State)};
|
{next_state, connecting, disconnect(State)};
|
||||||
{ok, NewState} ->
|
{ok, NewState} ->
|
||||||
{keep_state, NewState, ?maybe_send}
|
{keep_state, NewState, ?maybe_send}
|
||||||
|
@ -391,7 +391,7 @@ common(_StateName, info, {dispatch, _, Msg},
|
||||||
NewQ = replayq:append(Q, collect([Msg])),
|
NewQ = replayq:append(Q, collect([Msg])),
|
||||||
{keep_state, State#{replayq => NewQ}, ?maybe_send};
|
{keep_state, State#{replayq => NewQ}, ?maybe_send};
|
||||||
common(StateName, Type, Content, State) ->
|
common(StateName, Type, Content, State) ->
|
||||||
?INFO("Portal ~p discarded ~p type event at state ~p:\n~p",
|
?LOG(info, "Portal ~p discarded ~p type event at state ~p:\n~p",
|
||||||
[name(), Type, StateName, Content]),
|
[name(), Type, StateName, Content]),
|
||||||
{keep_state, State}.
|
{keep_state, State}.
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ retry_inflight(#{inflight := Inflight} = State,
|
||||||
{ok, NewState} ->
|
{ok, NewState} ->
|
||||||
retry_inflight(NewState, T);
|
retry_inflight(NewState, T);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?ERROR("Inflight retry failed\n~p", [Reason]),
|
?LOG(error, "Inflight retry failed\n~p", [Reason]),
|
||||||
{error, State#{inflight := Inflight ++ Remain}}
|
{error, State#{inflight := Inflight ++ Remain}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ do_send(State = #{inflight := Inflight}, QAckRef, [_ | _] = Batch) ->
|
||||||
batch => Batch}],
|
batch => Batch}],
|
||||||
{ok, State#{inflight := NewInflight}};
|
{ok, State#{inflight := NewInflight}};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?INFO("Batch produce failed\n~p", [Reason]),
|
?LOG(info, "Batch produce failed\n~p", [Reason]),
|
||||||
{error, State}
|
{error, State}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -82,4 +82,3 @@ to_broker_msg(#{qos := QoS, dup := Dup, retain := Retain, topic := Topic,
|
||||||
emqx_message:make(portal, QoS, Topic, Payload))).
|
emqx_message:make(portal, QoS, Topic, Payload))).
|
||||||
|
|
||||||
topic(Prefix, Topic) -> emqx_topic:prepend(Prefix, Topic).
|
topic(Prefix, Topic) -> emqx_topic:prepend(Prefix, Topic).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -103,4 +103,3 @@ poke(Node) ->
|
||||||
Node -> ok;
|
Node -> ok;
|
||||||
{badrpc, Reason} -> {error, Reason}
|
{badrpc, Reason} -> {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -15,6 +15,8 @@
|
||||||
-module(emqx_portal_sup).
|
-module(emqx_portal_sup).
|
||||||
-behavior(supervisor).
|
-behavior(supervisor).
|
||||||
|
|
||||||
|
-include("logger.hrl").
|
||||||
|
|
||||||
-export([start_link/0, start_link/1, portals/0]).
|
-export([start_link/0, start_link/1, portals/0]).
|
||||||
-export([create_portal/2, drop_portal/1]).
|
-export([create_portal/2, drop_portal/1]).
|
||||||
-export([init/1]).
|
-export([init/1]).
|
||||||
|
@ -55,6 +57,6 @@ drop_portal(Id) ->
|
||||||
ok ->
|
ok ->
|
||||||
supervisor:delete_child(?SUP, Id);
|
supervisor:delete_child(?SUP, Id);
|
||||||
Error ->
|
Error ->
|
||||||
emqx_logger:error("[Bridge] Delete bridge failed", [Error]),
|
?LOG(error, "[Bridge] Delete bridge failed", [Error]),
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Copyright (c) 2013-2013-2019 EMQ Inc. All rights reserved.
|
%%% Copyright (c) 2013-2019 EMQ Inc. All rights reserved.
|
||||||
%%%
|
%%%
|
||||||
%%% Licensed under the Apache License, Version 2.0 (the "License");
|
%%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%%% you may not use this file except in compliance with the License.
|
%%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2013-2019 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2019 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
Loading…
Reference in New Issue