Description:modify log title

Match-id-7cf4f9e93b57a81fcfcd677467e8bd2b78c551cc
This commit is contained in:
xxxx
2022-12-12 09:43:14 +08:00
parent 0a5e92d66e
commit faed0d55dd
69 changed files with 230 additions and 80 deletions
+4
View File
@@ -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;
+2 -3
View File
@@ -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 {
+1 -1
View File
@@ -29,11 +29,11 @@
#include <utility>
#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 {
+1 -1
View File
@@ -21,9 +21,9 @@
#include <sstream>
#include "anonymous_string.h"
#include "distributed_hardware_log.h"
#include "dinput_errcode.h"
#include "dinput_log.h"
#include "dinput_utils_tool.h"
namespace OHOS {
+3
View File
@@ -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" ]
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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 {
+3
View File
@@ -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" ]
@@ -28,11 +28,11 @@
#include <linux/uinput.h>
#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"
@@ -19,17 +19,16 @@
#include <string>
#include <vector>
#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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
+1 -1
View File
@@ -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 {
@@ -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"
@@ -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"
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -18,7 +18,7 @@
#include "ipc_types.h"
#include "parcel.h"
#include "distributed_hardware_log.h"
#include "dinput_log.h"
namespace OHOS {
namespace DistributedHardware {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -27,10 +27,10 @@
#include <linux/input.h>
#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 {
@@ -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"
@@ -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 {
@@ -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"
@@ -18,11 +18,11 @@
#include <sstream>
#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 {
@@ -22,14 +22,13 @@
#include <unistd.h>
#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 {
@@ -18,9 +18,9 @@
#include <securec.h>
#include "anonymous_string.h"
#include "distributed_hardware_log.h"
#include "constants_dinput.h"
#include "dinput_log.h"
#include "hidumper.h"
namespace OHOS {
@@ -21,7 +21,6 @@
#include <fstream>
#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"
@@ -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 {
+1 -1
View File
@@ -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",
]
@@ -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"
@@ -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"
@@ -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 {
@@ -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 {
@@ -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"
@@ -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"
@@ -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 {
+2
View File
@@ -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"
+1 -1
View File
@@ -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 {
+45
View File
@@ -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
+2 -1
View File
@@ -19,9 +19,10 @@
#include <cstdint>
#include <string>
#include "distributed_hardware_log.h"
#include "nlohmann/json.hpp"
#include "dinput_log.h"
namespace OHOS {
namespace DistributedHardware {
namespace DistributedInput {
+87
View File
@@ -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 <cstdio>
#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
+1 -1
View File
@@ -18,11 +18,11 @@
#include <mutex>
#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 {