diff --git a/include/emqx_client.hrl b/include/emqx_client.hrl index ce66c98d0..535b8ad55 100644 --- a/include/emqx_client.hrl +++ b/include/emqx_client.hrl @@ -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"); %% you may not use this file except in compliance with the License. diff --git a/include/logger.hrl b/include/logger.hrl index f87668cc7..bfa405170 100644 --- a/include/logger.hrl +++ b/include/logger.hrl @@ -39,3 +39,5 @@ begin (logger:log(Level,#{},#{report_cb => fun(_) -> {(Format), (Args)} end})) end). + +-define(LOG(Level, Format), ?LOG(Level, Format, [])). diff --git a/src/emqx_logger_formatter.erl b/src/emqx_logger_formatter.erl index 034eb8d36..dd94cceb6 100644 --- a/src/emqx_logger_formatter.erl +++ b/src/emqx_logger_formatter.erl @@ -1,7 +1,7 @@ %% %% %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"); %% you may not use this file except in compliance with the License. diff --git a/src/emqx_portal_connect.erl b/src/emqx_portal_connect.erl index f0b7474a5..9c2d168f3 100644 --- a/src/emqx_portal_connect.erl +++ b/src/emqx_portal_connect.erl @@ -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"); %% you may not use this file except in compliance with the License. @@ -54,8 +54,8 @@ start(Module, Config) -> {ok, Ref, Conn}; {error, Reason} -> Config1 = obfuscate(Config), - ?ERROR("Failed to connect with module=~p\n" - "config=~p\nreason:~p", [Module, Config1, Reason]), + ?LOG(error, "Failed to connect with module=~p\n" + "config=~p\nreason:~p", [Module, Config1, Reason]), error end. diff --git a/src/emqx_rpc.erl b/src/emqx_rpc.erl index 0245da838..e0d82f400 100644 --- a/src/emqx_rpc.erl +++ b/src/emqx_rpc.erl @@ -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"); %% 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) -> ?RPC:cast(Node, Mod, Fun, Args). - diff --git a/src/emqx_types.erl b/src/emqx_types.erl index 904e1df91..2fe34e853 100644 --- a/src/emqx_types.erl +++ b/src/emqx_types.erl @@ -31,7 +31,7 @@ -type(pubsub() :: publish | subscribe). -type(topic() :: binary()). -type(subid() :: binary() | atom()). --type(subopts() :: #{qos := eqmx_mqtt_types:qos(), +-type(subopts() :: #{qos := emqx_mqtt_types:qos(), share => binary(), atom() => term() }). @@ -59,4 +59,3 @@ -type(alarm() :: #alarm{}). -type(plugin() :: #plugin{}). -type(command() :: #command{}). - diff --git a/src/portal/emqx_portal.erl b/src/portal/emqx_portal.erl index 83a29521d..8ef764c39 100644 --- a/src/portal/emqx_portal.erl +++ b/src/portal/emqx_portal.erl @@ -279,7 +279,7 @@ standing_by(state_timeout, do_connect, State) -> standing_by({call, From}, _Call, _State) -> {keep_state_and_data, [{reply, From, {error,standing_by}}]}; 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}; 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), case ConnectFun(Subs) of {ok, ConnRef, Conn} -> - ?INFO("Portal ~p connected", [name()]), + ?LOG(info, "Portal ~p connected", [name()]), Action = {state_timeout, 0, connected}, {keep_state, State#{conn_ref => ConnRef, connection => Conn}, Action}; error -> @@ -348,7 +348,7 @@ connected(info, {disconnected, ConnRef, Reason}, #{conn_ref := ConnRefCurrent, connection := Conn} = State) -> case ConnRefCurrent =:= ConnRef of true -> - ?INFO("Portal ~p diconnected~nreason=~p", [name(), Conn, Reason]), + ?LOG(info, "Portal ~p diconnected~nreason=~p", [name(), Conn, Reason]), {next_state, connecting, State#{conn_ref := undefined, connection := undefined}}; false -> @@ -360,7 +360,7 @@ connected(info, {batch_ack, Ref}, State) -> keep_state_and_data; bad_order -> %% 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)}; {ok, NewState} -> {keep_state, NewState, ?maybe_send} @@ -391,7 +391,7 @@ common(_StateName, info, {dispatch, _, Msg}, NewQ = replayq:append(Q, collect([Msg])), {keep_state, State#{replayq => NewQ}, ?maybe_send}; 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]), {keep_state, State}. @@ -462,7 +462,7 @@ retry_inflight(#{inflight := Inflight} = State, {ok, NewState} -> retry_inflight(NewState, T); {error, Reason} -> - ?ERROR("Inflight retry failed\n~p", [Reason]), + ?LOG(error, "Inflight retry failed\n~p", [Reason]), {error, State#{inflight := Inflight ++ Remain}} end. @@ -493,7 +493,7 @@ do_send(State = #{inflight := Inflight}, QAckRef, [_ | _] = Batch) -> batch => Batch}], {ok, State#{inflight := NewInflight}}; {error, Reason} -> - ?INFO("Batch produce failed\n~p", [Reason]), + ?LOG(info, "Batch produce failed\n~p", [Reason]), {error, State} end. diff --git a/src/portal/emqx_portal_mqtt.erl b/src/portal/emqx_portal_mqtt.erl index d466a970d..3d0b90e30 100644 --- a/src/portal/emqx_portal_mqtt.erl +++ b/src/portal/emqx_portal_mqtt.erl @@ -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"); %% you may not use this file except in compliance with the License. diff --git a/src/portal/emqx_portal_msg.erl b/src/portal/emqx_portal_msg.erl index f8554f0b6..45cd64154 100644 --- a/src/portal/emqx_portal_msg.erl +++ b/src/portal/emqx_portal_msg.erl @@ -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"); %% 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))). topic(Prefix, Topic) -> emqx_topic:prepend(Prefix, Topic). - diff --git a/src/portal/emqx_portal_rpc.erl b/src/portal/emqx_portal_rpc.erl index fcd8b24e9..8b5600f77 100644 --- a/src/portal/emqx_portal_rpc.erl +++ b/src/portal/emqx_portal_rpc.erl @@ -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"); %% you may not use this file except in compliance with the License. @@ -103,4 +103,3 @@ poke(Node) -> Node -> ok; {badrpc, Reason} -> {error, Reason} end. - diff --git a/src/portal/emqx_portal_sup.erl b/src/portal/emqx_portal_sup.erl index 845136b7a..271c60423 100644 --- a/src/portal/emqx_portal_sup.erl +++ b/src/portal/emqx_portal_sup.erl @@ -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"); %% you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ -module(emqx_portal_sup). -behavior(supervisor). +-include("logger.hrl"). + -export([start_link/0, start_link/1, portals/0]). -export([create_portal/2, drop_portal/1]). -export([init/1]). @@ -55,6 +57,6 @@ drop_portal(Id) -> ok -> supervisor:delete_child(?SUP, Id); Error -> - emqx_logger:error("[Bridge] Delete bridge failed", [Error]), + ?LOG(error, "[Bridge] Delete bridge failed", [Error]), Error end. diff --git a/test/emqx_mqtt_packet_SUITE.erl b/test/emqx_mqtt_packet_SUITE.erl index 3be2617b0..0cd544c25 100644 --- a/test/emqx_mqtt_packet_SUITE.erl +++ b/test/emqx_mqtt_packet_SUITE.erl @@ -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"); %%% you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ case1_protocol_name(_) -> {ok, ?CONNACK_PACKET(?CONNACK_PROTO_VER), _} = raw_recv_pase(Data), Disconnect = gen_tcp:recv(Sock, 0), ?assertEqual({error, closed}, Disconnect). - + case2_protocol_ver(_) -> {ok, Sock} = emqx_client_sock:connect({127,0,0,1}, 1883, [binary, {packet, raw}, {active, false}], 3000), Packet = serialize(?CASE2_PROTOCAL_VER), diff --git a/test/emqx_portal_SUITE.erl b/test/emqx_portal_SUITE.erl index d9e7b38a2..2ceb7ea1e 100644 --- a/test/emqx_portal_SUITE.erl +++ b/test/emqx_portal_SUITE.erl @@ -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"); %% you may not use this file except in compliance with the License. diff --git a/test/emqx_portal_mqtt_tests.erl b/test/emqx_portal_mqtt_tests.erl index 788f5a4b2..1fcd71e79 100644 --- a/test/emqx_portal_mqtt_tests.erl +++ b/test/emqx_portal_mqtt_tests.erl @@ -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"); %% you may not use this file except in compliance with the License. diff --git a/test/emqx_portal_rpc_tests.erl b/test/emqx_portal_rpc_tests.erl index 5fd7608c0..363a0ee5a 100644 --- a/test/emqx_portal_rpc_tests.erl +++ b/test/emqx_portal_rpc_tests.erl @@ -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"); %% you may not use this file except in compliance with the License. diff --git a/test/emqx_portal_tests.erl b/test/emqx_portal_tests.erl index 18d7ed4cd..7cca66adc 100644 --- a/test/emqx_portal_tests.erl +++ b/test/emqx_portal_tests.erl @@ -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"); %% you may not use this file except in compliance with the License. diff --git a/test/emqx_protocol_SUITE.erl b/test/emqx_protocol_SUITE.erl index e48825d76..1ebb90876 100644 --- a/test/emqx_protocol_SUITE.erl +++ b/test/emqx_protocol_SUITE.erl @@ -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"); %% you may not use this file except in compliance with the License.