harmony 鸿蒙HiLog Development
HiLog Development
Overview
HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status.
This development guide is applicable to standard-system devices (reference memory ≥ 128 MB).
Available APIs
Table 1 List of C++ and C APIs
Table 2 Parameters of C++ APIs
How to Develop
C
Include the hilog header file in the .c source file.
#include "hilog/log.h"
Construct domain and tag.
#undef LOG_DOMAIN #undef LOG_TAG #define LOG_DOMAIN 0xD003200 // Indicates the service domain. The value ranges from 0xD000000 to 0xFFFFF. #define LOG_TAG "MY_TAG"
Print logs.
HILOG_INFO(LOG_CORE, "Failed to visit %{private}s, reason:%{public}d.", url, errno);
Configure compilation information. Specifically, add the subsystem SDK dependency to BUILD.gn.
external_deps = [ "hilog:libhilog" ]
C++
Include the hilog header file in the .h class definition header file.
#include "hilog/log.h"
If log printing is required for the class header file, define LABEL at the beginning of the class definition in the header file.
class MyClass { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD003200, "MY_TAG"}; ... }
If log printing is not required for the class definition header file, define LABEL in the class implementation file.
using namespace OHOS::HiviewDFX; static constexpr HiLogLabel LABEL = {LOG_CORE, 0xD003200, "MY_TAG"};
Print logs.
HiLog::Info(LABEL, "Failed to visit %{private}s, reason:%{public}d.", url, errno);
Configure compilation information. Specifically, add the subsystem SDK dependency to BUILD.gn.
external_deps = [ "hiviewdfx:libhilog" ]
你可能感兴趣的鸿蒙文章
harmony 鸿蒙AI Framework Development Guide
harmony 鸿蒙Neural Network Runtime Device Access
harmony 鸿蒙Application Privilege Configuration
harmony 鸿蒙Setting Up a Development Environment
harmony 鸿蒙Development Guidelines
harmony 鸿蒙Application Framework Overview
harmony 鸿蒙ArkCompiler Development
harmony 鸿蒙Window Title Bar Customization Development (ArkTS)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦