diff --git a/build/cmake/toolchain/linux.toolchain.cmake b/build/cmake/toolchain/linux.toolchain.cmake index 4a22fb5d..040c839c 100755 --- a/build/cmake/toolchain/linux.toolchain.cmake +++ b/build/cmake/toolchain/linux.toolchain.cmake @@ -32,15 +32,18 @@ set(TOOLCHAIN_NAME arm-linux-gnueabihf) set(TARGET_PLATFORM "linux") set(SUBMODULE_PATH_OF_IPCSDK "") set(PLATFORM_PATH "${CMAKE_CURRENT_SOURCE_DIR}") -set(TEST_COVERAGE "true") +set(TEST_COVERAGE "true") -# ------------ build curl + openssl ------------ start +# ------------ build curl + openssl ------------ # set(CURL_OPENSSL_LIB_SHARED_ENABLE "false") -# ------------ build curl + openssl ------------ end -# ------------ build clang-tidy ------------ start +# ------------ build curl + openssl end ------------ # +# ------------ build clang-tidy ------------ # set(CLANG_TIDY_SUPPORT "true") set(LLVM_PATH "/home/xiaojiazhu/project/tmp/llvm-project") -# ------------ build clang-tidy ------------ end -# ------------ build IpcConfig ------------ start +# ------------ build clang-tidy end ------------ # +# ------------ build IpcConfig ------------ # set(IPC_CONFIG_FILE_PATH "./ipc_config") -# ------------ build IpcConfig ------------ end \ No newline at end of file +# ------------ build IpcConfig end ------------ # +# ------------ build log ------------ # +set(LOG_SUPPORT "true") +# ------------ build log end ------------ # \ No newline at end of file diff --git a/utils/Log/README.md b/utils/Log/README.md new file mode 100644 index 00000000..62d188b8 --- /dev/null +++ b/utils/Log/README.md @@ -0,0 +1,44 @@ +# 1. 日志库 + +   日志库主要辅助调试和测试。 + +## 1.1. 基本需求: + +1. 日志类型:info / error / warning / trace ; +2. 通过预编译选择开启 / 关闭; +3. 通过多态动态加载 / 卸载; +4. 通过预编译加载 / 卸载某个模块的日志; + +## 1.2. 参考 + +* CMakeLists.txt脚本代码: +//build/global_config.cmake +``` +// 文件名宏定义__F_FILE__,指定文件实现打印文件名 + 行号功能 +// 不使用系统宏__FILE__是因为系统宏会打印绝对路径,日志阅读性差 +function(define_file_name target) + get_target_property(source_files "${target}" SOURCES) + foreach(source_file ${source_files}) + get_property(defs SOURCE "${source_file}" + PROPERTY COMPILE_DEFINITIONS) + get_filename_component(file_name "${source_file}" NAME) + list(APPEND defs "__F_FILE__=/"${file_name}/"") + set_property( + SOURCE "${source_file}" + PROPERTY COMPILE_DEFINITIONS ${defs}) + endforeach() +endfunction() +// LOG_DISABLE日志使能宏,指定文件开启 / 关闭日志功能 +function(log_disable target) + get_target_property(source_files "${target}" SOURCES) + foreach(source_file ${source_files}) + get_property(defs SOURCE "${source_file}" + PROPERTY COMPILE_DEFINITIONS) + get_filename_component(file_name "${source_file}" NAME) + list(APPEND defs "LOG_DISABLE") + set_property( + SOURCE "${source_file}" + PROPERTY COMPILE_DEFINITIONS ${defs}) + endforeach() +endfunction() +``` \ No newline at end of file diff --git a/utils/Log/include/ILog.h b/utils/Log/include/ILog.h index 239e5cc3..9554c8b9 100644 --- a/utils/Log/include/ILog.h +++ b/utils/Log/include/ILog.h @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 ILOG_H #define ILOG_H #ifdef __cplusplus diff --git a/utils/Log/include/ILogCpp.h b/utils/Log/include/ILogCpp.h index 7b1b264f..36739a90 100644 --- a/utils/Log/include/ILogCpp.h +++ b/utils/Log/include/ILogCpp.h @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 ILOGCPP_H #define ILOGCPP_H #include "ILog.h" diff --git a/utils/Log/src/ILogMakePtr.cpp b/utils/Log/src/ILogMakePtr.cpp index a1859b23..7d19556f 100644 --- a/utils/Log/src/ILogMakePtr.cpp +++ b/utils/Log/src/ILogMakePtr.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 "ILogMakePtr.h" #include "ILog.h" #include "ILogCpp.h" diff --git a/utils/Log/src/ILogMakePtr.h b/utils/Log/src/ILogMakePtr.h index c48a839d..07cb58d2 100644 --- a/utils/Log/src/ILogMakePtr.h +++ b/utils/Log/src/ILogMakePtr.h @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 ILOG_MAKE_PTR_H #define ILOG_MAKE_PTR_H #include "ILogCpp.h" diff --git a/utils/Log/src/Log.cpp b/utils/Log/src/Log.cpp index 55d2c836..0bc7938c 100644 --- a/utils/Log/src/Log.cpp +++ b/utils/Log/src/Log.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 "Log.h" #include "ILogCpp.h" #include diff --git a/utils/Log/src/Log.h b/utils/Log/src/Log.h index 91558019..b1e58401 100644 --- a/utils/Log/src/Log.h +++ b/utils/Log/src/Log.h @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 LOG_H # define LOG_H #include "ILog.h" diff --git a/utils/Log/src/LogEasylogging.cpp b/utils/Log/src/LogEasylogging.cpp index aa5cbd12..4ac7269c 100644 --- a/utils/Log/src/LogEasylogging.cpp +++ b/utils/Log/src/LogEasylogging.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 "ILog.h" #include "LogEasylogging.h" #include "easylogging++.h" diff --git a/utils/Log/src/LogEasylogging.h b/utils/Log/src/LogEasylogging.h index 5f5e46df..735adab5 100644 --- a/utils/Log/src/LogEasylogging.h +++ b/utils/Log/src/LogEasylogging.h @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 LOG_EASYLOGGING_H #define LOG_EASYLOGGING_H #include "ILogCpp.h" diff --git a/utils/Log/src/LogImpl.cpp b/utils/Log/src/LogImpl.cpp index 5fe431f5..3bb58a82 100644 --- a/utils/Log/src/LogImpl.cpp +++ b/utils/Log/src/LogImpl.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 "LogImpl.h" // int LogImpl::Log(const char *buff) // { diff --git a/utils/Log/src/LogImpl.h b/utils/Log/src/LogImpl.h index a061085d..e29c48dd 100644 --- a/utils/Log/src/LogImpl.h +++ b/utils/Log/src/LogImpl.h @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2023 Fancy Code. + * 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 LOG_IMPL_H #define LOG_IMPL_H #include "ILogCpp.h"