diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index e5cfcfc..93c98e5 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -179,6 +179,10 @@ namespace DistributedInput { const std::string PROPERTIES = "properties"; + const std::string DINPUT_LOG_TITLE_TAG = "DINPUT"; + + constexpr int32_t LOG_MAX_LEN = 4096; + constexpr uint32_t SCREEN_ID_DEFAULT = 0; constexpr uint32_t DEFAULT_VALUE = 0; diff --git a/common/include/input_check_param.cpp b/common/include/input_check_param.cpp index a9998ee..ed64077 100644 --- a/common/include/input_check_param.cpp +++ b/common/include/input_check_param.cpp @@ -13,11 +13,10 @@ * limitations under the License. */ +#include "input_check_param.h" #include "constants_dinput.h" -#include "distributed_hardware_log.h" - -#include "input_check_param.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index d1ccada..75c7027 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -29,11 +29,11 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "constants_dinput.h" #include "dinput_context.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dh_utils_tool.h" namespace OHOS { diff --git a/common/include/white_list_util.cpp b/common/include/white_list_util.cpp index fb7d7a5..e524b33 100644 --- a/common/include/white_list_util.cpp +++ b/common/include/white_list_util.cpp @@ -21,9 +21,9 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_utils_tool.h" namespace OHOS { diff --git a/dfx_utils/BUILD.gn b/dfx_utils/BUILD.gn index c339e24..8e563ac 100755 --- a/dfx_utils/BUILD.gn +++ b/dfx_utils/BUILD.gn @@ -28,12 +28,14 @@ ohos_shared_library("libdinput_dfx_utils") { "${frameworks_path}/include", "${dfx_utils_path}/include", "${service_common}/include", + "${utils_path}/include", "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk", "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", ] sources = [ + "${utils_path}/src/dinput_log.cpp", "src/hidumper.cpp", "src/hisysevent_util.cpp", ] @@ -52,6 +54,7 @@ ohos_shared_library("libdinput_dfx_utils") { external_deps = [ "c_utils:utils", "hisysevent_native:libhisysevent", + "hiviewdfx_hilog_native:libhilog", ] cflags_cc = [ "-DHILOG_ENABLE" ] diff --git a/dfx_utils/src/hidumper.cpp b/dfx_utils/src/hidumper.cpp index 59a7b49..a9555e7 100644 --- a/dfx_utils/src/hidumper.cpp +++ b/dfx_utils/src/hidumper.cpp @@ -16,9 +16,9 @@ #include "hidumper.h" #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_softbus_define.h" namespace OHOS { diff --git a/dfx_utils/src/hisysevent_util.cpp b/dfx_utils/src/hisysevent_util.cpp index 64d5d01..546a568 100644 --- a/dfx_utils/src/hisysevent_util.cpp +++ b/dfx_utils/src/hisysevent_util.cpp @@ -17,7 +17,7 @@ #include "anonymous_string.h" #include "dinput_errcode.h" -#include "distributed_hardware_log.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/dfx_utils/test/dfxtest/BUILD.gn b/dfx_utils/test/dfxtest/BUILD.gn index b1f25f0..2d4416e 100644 --- a/dfx_utils/test/dfxtest/BUILD.gn +++ b/dfx_utils/test/dfxtest/BUILD.gn @@ -38,12 +38,14 @@ ohos_unittest("distributed_input_dfx_test") { "${frameworks_path}/include", "${dfx_utils_path}/include", "${service_common}/include", + "${utils_path}/include", "//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk", "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include", ] sources = [ + "${utils_path}/src/dinput_log.cpp", "${dfx_utils_path}/src/hidumper.cpp", "${dfx_utils_path}/src/hisysevent_util.cpp", "distributed_input_dfx_test.cpp", @@ -71,6 +73,7 @@ ohos_unittest("distributed_input_dfx_test") { external_deps = [ "c_utils:utils", "hisysevent_native:libhisysevent", + "hiviewdfx_hilog_native:libhilog", ] cflags_cc = [ "-DHILOG_ENABLE" ] diff --git a/inputdevicehandler/src/distributed_input_handler.cpp b/inputdevicehandler/src/distributed_input_handler.cpp index d549aa1..b16cd60 100644 --- a/inputdevicehandler/src/distributed_input_handler.cpp +++ b/inputdevicehandler/src/distributed_input_handler.cpp @@ -28,11 +28,11 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "nlohmann/json.hpp" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_softbus_define.h" #include "softbus_bus_center.h" diff --git a/interfaces/inner_kits/include/distributed_input_kit.h b/interfaces/inner_kits/include/distributed_input_kit.h index 27261b9..9a9039f 100644 --- a/interfaces/inner_kits/include/distributed_input_kit.h +++ b/interfaces/inner_kits/include/distributed_input_kit.h @@ -19,17 +19,16 @@ #include #include -#include "distributed_hardware_log.h" - #include "constants_dinput.h" +#include "dinput_log.h" #include "distributed_input_client.h" +#include "i_prepare_d_input_call_back.h" #include "i_register_d_input_call_back.h" #include "i_start_d_input_call_back.h" #include "i_stop_d_input_call_back.h" #include "i_start_stop_d_inputs_call_back.h" #include "i_start_stop_result_call_back.h" #include "i_unregister_d_input_call_back.h" -#include "i_prepare_d_input_call_back.h" #include "i_unprepare_d_input_call_back.h" namespace OHOS { diff --git a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp index 5fd70b4..dea9bec 100644 --- a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp +++ b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp @@ -15,12 +15,12 @@ #include "distributed_input_client.h" -#include "distributed_hardware_log.h" #include "nlohmann/json.hpp" #include "constants_dinput.h" #include "dinput_context.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "white_list_util.h" namespace OHOS { diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp index a43c535..759dea0 100644 --- a/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/add_white_list_infos_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "add_white_list_infos_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp b/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp index f3c255f..622f166 100644 --- a/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp +++ b/interfaces/ipc/src/add_white_list_infos_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "add_white_list_infos_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp index f6881af..ca978e5 100644 --- a/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/del_white_list_infos_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "del_white_list_infos_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp b/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp index 28f19e8..0c2b6b5 100644 --- a/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp +++ b/interfaces/ipc/src/del_white_list_infos_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "del_white_list_infos_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/dinput_sa_manager.cpp b/interfaces/ipc/src/dinput_sa_manager.cpp index d423df8..4f3969b 100644 --- a/interfaces/ipc/src/dinput_sa_manager.cpp +++ b/interfaces/ipc/src/dinput_sa_manager.cpp @@ -15,12 +15,12 @@ #include "dinput_sa_manager.h" -#include "distributed_hardware_log.h" #include "iservice_registry.h" #include "system_ability_definition.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index 11949e9..62c2831 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -16,7 +16,6 @@ #include "distributed_input_client.h" #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "iservice_registry.h" #include "nlohmann/json.hpp" #include "system_ability_definition.h" @@ -24,6 +23,7 @@ #include "constants_dinput.h" #include "dinput_context.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_utils_tool.h" #include "distributed_input_source_proxy.h" #include "input_check_param.h" diff --git a/interfaces/ipc/src/distributed_input_sink_proxy.cpp b/interfaces/ipc/src/distributed_input_sink_proxy.cpp index a279fb2..7a435b5 100644 --- a/interfaces/ipc/src/distributed_input_sink_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_sink_proxy.cpp @@ -16,9 +16,9 @@ #include "distributed_input_sink_proxy.h" #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_utils_tool.h" #include "i_get_sink_screen_infos_call_back.h" diff --git a/interfaces/ipc/src/distributed_input_sink_stub.cpp b/interfaces/ipc/src/distributed_input_sink_stub.cpp index 060b05c..608b198 100644 --- a/interfaces/ipc/src/distributed_input_sink_stub.cpp +++ b/interfaces/ipc/src/distributed_input_sink_stub.cpp @@ -16,10 +16,10 @@ #include "distributed_input_sink_stub.h" #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "i_sharing_dhid_listener.h" namespace OHOS { diff --git a/interfaces/ipc/src/distributed_input_source_proxy.cpp b/interfaces/ipc/src/distributed_input_source_proxy.cpp index fbae468..25e95b3 100644 --- a/interfaces/ipc/src/distributed_input_source_proxy.cpp +++ b/interfaces/ipc/src/distributed_input_source_proxy.cpp @@ -15,9 +15,8 @@ #include "distributed_input_source_proxy.h" -#include "distributed_hardware_log.h" - #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/distributed_input_source_stub.cpp b/interfaces/ipc/src/distributed_input_source_stub.cpp index 774b98b..1d95ff2 100644 --- a/interfaces/ipc/src/distributed_input_source_stub.cpp +++ b/interfaces/ipc/src/distributed_input_source_stub.cpp @@ -15,10 +15,9 @@ #include "distributed_input_source_stub.h" -#include "distributed_hardware_log.h" - #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp b/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp index 42dfde3..c20011f 100644 --- a/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp +++ b/interfaces/ipc/src/get_sink_screen_infos_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "get_sink_screen_infos_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/get_sink_screen_infos_call_back_stub.cpp b/interfaces/ipc/src/get_sink_screen_infos_call_back_stub.cpp index cc9724d..7537ec5 100644 --- a/interfaces/ipc/src/get_sink_screen_infos_call_back_stub.cpp +++ b/interfaces/ipc/src/get_sink_screen_infos_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "get_sink_screen_infos_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/input_node_listener_proxy.cpp b/interfaces/ipc/src/input_node_listener_proxy.cpp index e136f6c..fe7c1ea 100644 --- a/interfaces/ipc/src/input_node_listener_proxy.cpp +++ b/interfaces/ipc/src/input_node_listener_proxy.cpp @@ -15,10 +15,11 @@ #include "input_node_listener_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/input_node_listener_stub.cpp b/interfaces/ipc/src/input_node_listener_stub.cpp index 2f20cfc..348a42b 100644 --- a/interfaces/ipc/src/input_node_listener_stub.cpp +++ b/interfaces/ipc/src/input_node_listener_stub.cpp @@ -15,11 +15,11 @@ #include "input_node_listener_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp index c138864..18b4c28 100644 --- a/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/prepare_d_input_call_back_proxy.cpp @@ -15,11 +15,11 @@ #include "prepare_d_input_call_back_proxy.h" -#include "distributed_hardware_log.h" - #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp b/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp index 2be936e..0796aa4 100644 --- a/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/prepare_d_input_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "prepare_d_input_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp index ba7249d..58302e6 100644 --- a/interfaces/ipc/src/register_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/register_d_input_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "register_d_input_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/register_d_input_call_back_stub.cpp b/interfaces/ipc/src/register_d_input_call_back_stub.cpp index 031e7ee..935c6ca 100644 --- a/interfaces/ipc/src/register_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/register_d_input_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "register_d_input_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/sharing_dhid_listener_proxy.cpp b/interfaces/ipc/src/sharing_dhid_listener_proxy.cpp index b28b678..daabdf8 100644 --- a/interfaces/ipc/src/sharing_dhid_listener_proxy.cpp +++ b/interfaces/ipc/src/sharing_dhid_listener_proxy.cpp @@ -15,11 +15,12 @@ #include "sharing_dhid_listener_proxy.h" -#include "distributed_hardware_log.h" -#include "dinput_errcode.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_errcode.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/sharing_dhid_listener_stub.cpp b/interfaces/ipc/src/sharing_dhid_listener_stub.cpp index e5ed558..4410adb 100644 --- a/interfaces/ipc/src/sharing_dhid_listener_stub.cpp +++ b/interfaces/ipc/src/sharing_dhid_listener_stub.cpp @@ -15,11 +15,11 @@ #include "sharing_dhid_listener_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/simulation_event_listener_proxy.cpp b/interfaces/ipc/src/simulation_event_listener_proxy.cpp index fad571b..4412a77 100644 --- a/interfaces/ipc/src/simulation_event_listener_proxy.cpp +++ b/interfaces/ipc/src/simulation_event_listener_proxy.cpp @@ -15,11 +15,12 @@ #include "simulation_event_listener_proxy.h" -#include "distributed_hardware_log.h" -#include "dinput_errcode.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_errcode.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/simulation_event_listener_stub.cpp b/interfaces/ipc/src/simulation_event_listener_stub.cpp index 3fba1b5..34b2b70 100644 --- a/interfaces/ipc/src/simulation_event_listener_stub.cpp +++ b/interfaces/ipc/src/simulation_event_listener_stub.cpp @@ -15,11 +15,11 @@ #include "simulation_event_listener_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp index 22bb7c9..1384901 100644 --- a/interfaces/ipc/src/start_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_d_input_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "start_d_input_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/start_d_input_call_back_stub.cpp b/interfaces/ipc/src/start_d_input_call_back_stub.cpp index 209b71f..b9243b1 100644 --- a/interfaces/ipc/src/start_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/start_d_input_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "start_d_input_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp b/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp index 703c621..d2a4087 100644 --- a/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_stop_d_inputs_call_back_proxy.cpp @@ -18,7 +18,7 @@ #include "ipc_types.h" #include "parcel.h" -#include "distributed_hardware_log.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/start_stop_d_inputs_call_back_stub.cpp b/interfaces/ipc/src/start_stop_d_inputs_call_back_stub.cpp index 36f403f..748b7a6 100644 --- a/interfaces/ipc/src/start_stop_d_inputs_call_back_stub.cpp +++ b/interfaces/ipc/src/start_stop_d_inputs_call_back_stub.cpp @@ -19,7 +19,7 @@ #include "constants_dinput.h" #include "dinput_errcode.h" -#include "distributed_hardware_log.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/start_stop_result_call_back_proxy.cpp b/interfaces/ipc/src/start_stop_result_call_back_proxy.cpp index f1b23fe..8307480 100644 --- a/interfaces/ipc/src/start_stop_result_call_back_proxy.cpp +++ b/interfaces/ipc/src/start_stop_result_call_back_proxy.cpp @@ -17,7 +17,7 @@ #include "parcel.h" #include "dinput_errcode.h" -#include "distributed_hardware_log.h" +#include "dinput_log.h" #include "start_stop_result_call_back_proxy.h" namespace OHOS { diff --git a/interfaces/ipc/src/start_stop_result_call_back_stub.cpp b/interfaces/ipc/src/start_stop_result_call_back_stub.cpp index c756149..f94640a 100644 --- a/interfaces/ipc/src/start_stop_result_call_back_stub.cpp +++ b/interfaces/ipc/src/start_stop_result_call_back_stub.cpp @@ -19,7 +19,7 @@ #include "constants_dinput.h" #include "dinput_errcode.h" -#include "distributed_hardware_log.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp index 5c5c1c5..dd787fd 100644 --- a/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/stop_d_input_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "stop_d_input_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp index bfb103e..64f8d5f 100644 --- a/interfaces/ipc/src/stop_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/stop_d_input_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "stop_d_input_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp index 2e47eee..ede240e 100644 --- a/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/unprepare_d_input_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "unprepare_d_input_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp b/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp index 5510c1a..f248c93 100644 --- a/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/unprepare_d_input_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "unprepare_d_input_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp index 2aca92e..1648dfd 100644 --- a/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp +++ b/interfaces/ipc/src/unregister_d_input_call_back_proxy.cpp @@ -15,10 +15,11 @@ #include "unregister_d_input_call_back_proxy.h" -#include "distributed_hardware_log.h" #include "ipc_types.h" #include "parcel.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp b/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp index 63e7c56..6270c3c 100644 --- a/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp +++ b/interfaces/ipc/src/unregister_d_input_call_back_stub.cpp @@ -15,11 +15,11 @@ #include "unregister_d_input_call_back_stub.h" -#include "distributed_hardware_log.h" #include "string_ex.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/ipc/test/clientunittest/mock_samanager.cpp b/interfaces/ipc/test/clientunittest/mock_samanager.cpp index 588c25a..7da39f4 100644 --- a/interfaces/ipc/test/clientunittest/mock_samanager.cpp +++ b/interfaces/ipc/test/clientunittest/mock_samanager.cpp @@ -15,7 +15,6 @@ #include "dinput_sa_manager.h" -#include "distributed_hardware_log.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -23,6 +22,7 @@ #include "distributed_input_source_manager.h" #include "distributed_input_sink_manager.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/sink/inputcollector/src/distributed_input_collector.cpp b/services/sink/inputcollector/src/distributed_input_collector.cpp index b740aa0..1743a9d 100644 --- a/services/sink/inputcollector/src/distributed_input_collector.cpp +++ b/services/sink/inputcollector/src/distributed_input_collector.cpp @@ -27,10 +27,10 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "nlohmann/json.hpp" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index 78f3d46..24dea3f 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -23,7 +23,6 @@ #include "anonymous_string.h" #include "dinput_softbus_define.h" #include "distributed_hardware_fwk_kit.h" -#include "distributed_hardware_log.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "nlohmann/json.hpp" @@ -37,6 +36,7 @@ #include "dinput_context.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_sa_process_state.h" #include "dinput_utils_tool.h" #include "hidumper.h" diff --git a/services/sink/transport/src/distributed_input_sink_switch.cpp b/services/sink/transport/src/distributed_input_sink_switch.cpp index e0af6b0..c199230 100644 --- a/services/sink/transport/src/distributed_input_sink_switch.cpp +++ b/services/sink/transport/src/distributed_input_sink_switch.cpp @@ -16,10 +16,10 @@ #include "distributed_input_sink_switch.h" #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "constants_dinput.h" #include "dinput_errcode.h" +#include "dinput_log.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index bb9992f..a6fcd96 100644 --- a/services/sink/transport/src/distributed_input_sink_transport.cpp +++ b/services/sink/transport/src/distributed_input_sink_transport.cpp @@ -21,12 +21,12 @@ #include "anonymous_string.h" #include "distributed_hardware_fwk_kit.h" -#include "distributed_hardware_log.h" #include "securec.h" #include "constants_dinput.h" #include "dinput_context.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_softbus_define.h" #include "dinput_utils_tool.h" #include "hidumper.h" diff --git a/services/source/inputinject/src/distributed_input_inject.cpp b/services/source/inputinject/src/distributed_input_inject.cpp index 9d9a055..bea0f0c 100644 --- a/services/source/inputinject/src/distributed_input_inject.cpp +++ b/services/source/inputinject/src/distributed_input_inject.cpp @@ -18,11 +18,11 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "dh_utils_tool.h" #include "nlohmann/json.hpp" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_utils_tool.h" namespace OHOS { diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 744c561..c2beaa1 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -22,14 +22,13 @@ #include #include "anonymous_string.h" -#include "dinput_utils_tool.h" -#include "distributed_hardware_log.h" - #include "softbus_bus_center.h" #include "dinput_context.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "dinput_softbus_define.h" +#include "dinput_utils_tool.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/source/inputinject/src/virtual_device.cpp b/services/source/inputinject/src/virtual_device.cpp index 444db30..fd1d021 100644 --- a/services/source/inputinject/src/virtual_device.cpp +++ b/services/source/inputinject/src/virtual_device.cpp @@ -18,9 +18,9 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "constants_dinput.h" +#include "dinput_log.h" #include "hidumper.h" namespace OHOS { diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 0c2b6d4..f854f78 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -21,7 +21,6 @@ #include #include "anonymous_string.h" -#include "distributed_hardware_log.h" #include "dinput_softbus_define.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" @@ -36,6 +35,7 @@ #include "constants_dinput.h" #include "dinput_errcode.h" #include "dinput_hitrace.h" +#include "dinput_log.h" #include "dinput_sa_process_state.h" #include "dinput_utils_tool.h" #include "distributed_input_client.h" diff --git a/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp b/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp index 21c7aac..ea2b9b6 100644 --- a/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_sa_cli_mgr.cpp @@ -19,9 +19,10 @@ #include "iservice_registry.h" #include "system_ability_definition.h" -#include "distributed_hardware_log.h" #include "anonymous_string.h" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/services/source/transport/BUILD.gn b/services/source/transport/BUILD.gn index 69982d0..074ee73 100755 --- a/services/source/transport/BUILD.gn +++ b/services/source/transport/BUILD.gn @@ -45,7 +45,7 @@ ohos_shared_library("libdinput_source_trans") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"distributedinpusourcetransport\"", + "DH_LOG_TAG=\"distributedinputsourcetransport\"", "LOG_DOMAIN=0xD004100", ] diff --git a/services/source/transport/src/distributed_input_source_transport.cpp b/services/source/transport/src/distributed_input_source_transport.cpp index f766fad..f89d57d 100644 --- a/services/source/transport/src/distributed_input_source_transport.cpp +++ b/services/source/transport/src/distributed_input_source_transport.cpp @@ -20,7 +20,6 @@ #include "anonymous_string.h" #include "distributed_hardware_fwk_kit.h" -#include "distributed_hardware_log.h" #include "ipc_skeleton.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -29,6 +28,7 @@ #include "dinput_context.h" #include "dinput_errcode.h" #include "dinput_hitrace.h" +#include "dinput_log.h" #include "dinput_softbus_define.h" #include "dinput_utils_tool.h" #include "distributed_input_inject.h" diff --git a/sinkhandler/src/distributed_input_sink_handler.cpp b/sinkhandler/src/distributed_input_sink_handler.cpp index 3971e8a..6fddbfb 100644 --- a/sinkhandler/src/distributed_input_sink_handler.cpp +++ b/sinkhandler/src/distributed_input_sink_handler.cpp @@ -15,9 +15,8 @@ #include "distributed_input_sink_handler.h" -#include "distributed_hardware_log.h" - #include "dinput_errcode.h" +#include "dinput_log.h" #include "hisysevent_util.h" #include "i_distributed_sink_input.h" #include "load_d_input_sink_callback.h" diff --git a/sinkhandler/src/load_d_input_sink_callback.cpp b/sinkhandler/src/load_d_input_sink_callback.cpp index ee7d171..dd61e7d 100644 --- a/sinkhandler/src/load_d_input_sink_callback.cpp +++ b/sinkhandler/src/load_d_input_sink_callback.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include "distributed_hardware_log.h" +#include "load_d_input_sink_callback.h" +#include "dinput_log.h" #include "distributed_input_sink_handler.h" #include "hisysevent_util.h" -#include "load_d_input_sink_callback.h" namespace OHOS { namespace DistributedHardware { diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index 715fb3f..390a61a 100644 --- a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -13,12 +13,12 @@ * limitations under the License. */ -#include "distributed_hardware_log.h" #include "nlohmann/json.hpp" #include "constants_dinput.h" -#include "distributed_input_client.h" #include "dinput_errcode.h" +#include "dinput_log.h" +#include "distributed_input_client.h" #include "white_list_util.h" namespace OHOS { diff --git a/sourcehandler/src/distributed_input_source_handler.cpp b/sourcehandler/src/distributed_input_source_handler.cpp index 2cf4f0b..5e2556d 100644 --- a/sourcehandler/src/distributed_input_source_handler.cpp +++ b/sourcehandler/src/distributed_input_source_handler.cpp @@ -15,9 +15,8 @@ #include "distributed_input_source_handler.h" -#include "distributed_hardware_log.h" - #include "dinput_errcode.h" +#include "dinput_log.h" #include "hisysevent_util.h" #include "i_distributed_source_input.h" #include "load_d_input_source_callback.h" diff --git a/sourcehandler/src/load_d_input_source_callback.cpp b/sourcehandler/src/load_d_input_source_callback.cpp index 031c971..1cb5df4 100644 --- a/sourcehandler/src/load_d_input_source_callback.cpp +++ b/sourcehandler/src/load_d_input_source_callback.cpp @@ -15,8 +15,7 @@ #include "load_d_input_source_callback.h" -#include "distributed_hardware_log.h" - +#include "dinput_log.h" #include "distributed_input_source_handler.h" #include "hisysevent_util.h" diff --git a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index 0531867..bd6b7d8 100644 --- a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -13,12 +13,13 @@ * limitations under the License. */ +#include "distributed_input_client.h" + #include "nlohmann/json.hpp" -#include "distributed_hardware_log.h" #include "constants_dinput.h" -#include "distributed_input_client.h" #include "dinput_errcode.h" +#include "dinput_log.h" #include "white_list_util.h" namespace OHOS { diff --git a/utils/BUILD.gn b/utils/BUILD.gn index fa53038..de8a3a2 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -37,6 +37,7 @@ ohos_shared_library("libdinput_utils") { sources = [ "src/dinput_context.cpp", + "src/dinput_log.cpp", "src/dinput_utils_tool.cpp", "src/dinput_sa_process_state.cpp", ] @@ -58,6 +59,7 @@ ohos_shared_library("libdinput_utils") { "dsoftbus:softbus_client", "samgr:samgr_proxy", "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", ] subsystem_name = "distributedhardware" diff --git a/utils/include/dinput_context.h b/utils/include/dinput_context.h index 0724515..4dcf248 100644 --- a/utils/include/dinput_context.h +++ b/utils/include/dinput_context.h @@ -30,12 +30,12 @@ #include "constants.h" #include "device_type.h" #include "distributed_hardware_fwk_kit.h" -#include "distributed_hardware_log.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "nlohmann/json.hpp" #include "system_ability_definition.h" +#include "dinput_log.h" #include "i_dinput_context.h" namespace OHOS { diff --git a/utils/include/dinput_log.h b/utils/include/dinput_log.h new file mode 100644 index 0000000..3e1e431 --- /dev/null +++ b/utils/include/dinput_log.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DINPUT_LOG_H +#define OHOS_DINPUT_LOG_H + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +typedef enum { + DH_LOG_DEBUG, + DH_LOG_INFO, + DH_LOG_WARN, + DH_LOG_ERROR, +} DHLogLevel; + +void DHLog(DHLogLevel logLevel, const char *fmt, ...); + +#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) + +#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ + (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DINPUT_LOG_H diff --git a/utils/include/dinput_utils_tool.h b/utils/include/dinput_utils_tool.h index 655bfe0..bf906a6 100644 --- a/utils/include/dinput_utils_tool.h +++ b/utils/include/dinput_utils_tool.h @@ -19,9 +19,10 @@ #include #include -#include "distributed_hardware_log.h" #include "nlohmann/json.hpp" +#include "dinput_log.h" + namespace OHOS { namespace DistributedHardware { namespace DistributedInput { diff --git a/utils/src/dinput_log.cpp b/utils/src/dinput_log.cpp new file mode 100644 index 0000000..b9d3ef4 --- /dev/null +++ b/utils/src/dinput_log.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dinput_log.h" + +#include "constants_dinput.h" +#include "securec.h" + +#ifdef HI_LOG_ENABLE +#include "hilog/log.h" +#else +#include +#endif + +namespace OHOS { +namespace DistributedHardware { +namespace DistributedInput { +static void DHLogOut(DHLogLevel logLevel, const char *logBuf) +{ +#ifdef HI_LOG_ENABLE + LogLevel hiLogLevel = LOG_INFO; + switch (logLevel) { + case DH_LOG_DEBUG: + hiLogLevel = LOG_DEBUG; + break; + case DH_LOG_INFO: + hiLogLevel = LOG_INFO; + break; + case DH_LOG_WARN: + hiLogLevel = LOG_WARN; + break; + case DH_LOG_ERROR: + hiLogLevel = LOG_ERROR; + break; + default: + break; + } + (void)HiLogPrint(LOG_CORE, hiLogLevel, LOG_DOMAIN, DINPUT_LOG_TITLE_TAG.c_str(), "%{public}s", logBuf); +#else + switch (logLevel) { + case DH_LOG_DEBUG: + printf("[D]%s\n", logBuf); + break; + case DH_LOG_INFO: + printf("[I]%s\n", logBuf); + break; + case DH_LOG_WARN: + printf("[W]%s\n", logBuf); + break; + case DH_LOG_ERROR: + printf("[E]%s\n", logBuf); + break; + default: + break; + } +#endif +} + +void DHLog(DHLogLevel logLevel, const char *fmt, ...) +{ + char logBuf[LOG_MAX_LEN] = {0}; + va_list arg; + va_start(arg, fmt); + + int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); + va_end(arg); + if (ret < 0) { + DHLogOut(logLevel, "DH log length error."); + return; + } + DHLogOut(logLevel, logBuf); +} +} // namespace DistributedInput +} // namespace DistributedHardware +} // namespace OHOS diff --git a/utils/src/dinput_sa_process_state.cpp b/utils/src/dinput_sa_process_state.cpp index cc8e5b9..b717443 100644 --- a/utils/src/dinput_sa_process_state.cpp +++ b/utils/src/dinput_sa_process_state.cpp @@ -18,11 +18,11 @@ #include #include "distributed_hardware_fwk_kit.h" -#include "distributed_hardware_log.h" #include "ipublisher_listener.h" #include "constants_dinput.h" #include "dinput_context.h" +#include "dinput_log.h" #include "hisysevent_util.h" namespace OHOS {