diff --git a/frameworks/libhilog/BUILD.gn b/frameworks/libhilog/BUILD.gn index 274c3f18a93f174e24fb02d1dca097fb363d497e..fe1a6623f28b1293597e14f5cd228e2a27a2cf48 100644 --- a/frameworks/libhilog/BUILD.gn +++ b/frameworks/libhilog/BUILD.gn @@ -42,7 +42,7 @@ config("libhilog_config") { template("libhilog_source") { forward_variables_from(invoker, "*") ohos_source_set(target_name) { - if (platform != "windows" && platform != "mac") { + if (platform != "windows" && platform != "mac" && platform != "linux") { param_sources = [ "$param_root/properties.cpp" ] ioctl_sources = [ "$ioctl_root/log_ioctl.cpp" ] @@ -70,7 +70,7 @@ template("libhilog_source") { "hilog.cpp", "hilog_printf.cpp", ] - if (platform != "windows" && platform != "mac") { + if (platform != "windows" && platform != "mac" && platform != "linux") { sources += param_sources sources += ioctl_sources sources += socket_sources @@ -84,6 +84,9 @@ template("libhilog_source") { defines += [ "__WINDOWS__" ] } else if (platform == "mac") { defines += [ "__MAC__" ] + } else if (platform == "linux") { + cflags_cc = [ "-std=c++17" ] + defines += [ "__LINUX__" ] } else { defines = [ "__RECV_MSG_WITH_UCRED_" ] if (use_musl) { @@ -95,7 +98,7 @@ template("libhilog_source") { deps = [ "//third_party/bounds_checking_function:libsec_shared" ] - if (platform != "windows" && platform != "mac") { + if (platform != "windows" && platform != "mac" && platform != "linux") { external_deps = [ "init:libbegetutil" ] } diff --git a/frameworks/libhilog/hilog_printf.cpp b/frameworks/libhilog/hilog_printf.cpp index eb8be9db05ed7b3d7016221f37e45485cb4a2b1d..990d6ac79a9f2a9d2ca9568757fad03ff6dcc44a 100644 --- a/frameworks/libhilog/hilog_printf.cpp +++ b/frameworks/libhilog/hilog_printf.cpp @@ -21,6 +21,11 @@ #include #include +#ifdef __LINUX__ +#include +#endif + + #ifndef __WINDOWS__ #include #else @@ -37,7 +42,7 @@ #include "vsnprintf_s_p.h" #include "log_utils.h" -#if not (defined( __WINDOWS__ ) || defined( __MAC__ )) +#if not (defined( __WINDOWS__ ) || defined( __MAC__ ) || defined( __LINUX__ )) #include "properties.h" #include "hilog_input_socket_client.h" #else @@ -84,7 +89,7 @@ static uint16_t GetFinalLevel(unsigned int domain, const std::string& tag) { // Priority: TagLevel > DomainLevel > GlobalLevel // LOG_LEVEL_MIN is default Level -#if not (defined( __WINDOWS__ ) || defined( __MAC__ )) +#if not (defined( __WINDOWS__ ) || defined( __MAC__ ) || defined( __LINUX__ )) uint16_t tagLevel = GetTagLevel(tag); if (tagLevel != LOG_LEVEL_MIN) { return tagLevel; @@ -99,7 +104,7 @@ static uint16_t GetFinalLevel(unsigned int domain, const std::string& tag) #endif } -#if not (defined( __WINDOWS__ ) || defined( __MAC__ )) +#if not (defined( __WINDOWS__ ) || defined( __MAC__ ) || defined( __LINUX__ )) static int HiLogFlowCtrlProcess(int len, const struct timespec &ts, bool debug) { static uint32_t processQuota = 0; @@ -206,7 +211,7 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int } /* format log string */ -#if not (defined( __WINDOWS__ ) || defined( __MAC__ )) +#if not (defined( __WINDOWS__ ) || defined( __MAC__ ) || defined( __LINUX__ )) bool debug = IsDebugOn(); bool priv = (!debug) && IsPrivateSwitchOn(); #else @@ -258,7 +263,7 @@ int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int (void)memcpy_s(g_hiLogLastFatalMessage, sizeof(g_hiLogLastFatalMessage), buf, sizeof(buf)); } -#if not (defined( __WINDOWS__ ) || defined( __MAC__ )) +#if not (defined( __WINDOWS__ ) || defined( __MAC__ ) || defined( __LINUX__ )) /* flow control */ if (IsProcessSwitchOn()) { ret = HiLogFlowCtrlProcess(tagLen + logLen - traceBufLen, ts_mono, debug); diff --git a/frameworks/libhilog/include/hilog_common.h b/frameworks/libhilog/include/hilog_common.h index 81f77202cc2fd7d49bce5737450177f0e7c51d96..e6cdd5e6c38a478fdac03b98a4d20233fc979658 100644 --- a/frameworks/libhilog/include/hilog_common.h +++ b/frameworks/libhilog/include/hilog_common.h @@ -17,6 +17,7 @@ #define HILOG_COMMON_H #include +#include #include #include #include diff --git a/frameworks/libhilog/utils/log_utils.cpp b/frameworks/libhilog/utils/log_utils.cpp index 47f6516dde84a91ab9a77f6e1eae9a793771839a..cc43f67b7db63c76529ea5433cb2d8d620d1a561 100644 --- a/frameworks/libhilog/utils/log_utils.cpp +++ b/frameworks/libhilog/utils/log_utils.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/hilog.gni b/hilog.gni index b3faa93171d001773f21661c74f101e964100308..50b85be0ba33115b0c06f413c5bcd0169bc68257 100644 --- a/hilog.gni +++ b/hilog.gni @@ -15,4 +15,5 @@ platforms = [ "ohos", "windows", "mac", + "linux", ] diff --git a/interfaces/native/innerkits/BUILD.gn b/interfaces/native/innerkits/BUILD.gn index ecce4ed1f54e6e98d121e04622d4ccb88791f990..c01daf46e137025a796650c08e2ed5fe9d5e6e45 100644 --- a/interfaces/native/innerkits/BUILD.gn +++ b/interfaces/native/innerkits/BUILD.gn @@ -49,7 +49,7 @@ foreach(item, platforms) { platform = item } } - if (item == "windows" || item == "mac") { + if (item == "windows" || item == "mac" || item == "linux") { libhilog("libhilog_" + item) { platform = item }