diff --git a/README.md b/README.md index c43ec4fcbad56a6d2588050bcb3132fd0d333966..1d01b7d5dacfae4e7ff8681e0a36ca79f8ffe215 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,76 @@ -# HiLog +# HiLog组件 -- [Introduction](#section11660541593) -- [Directory Structure](#section161941989596) -- [Constraints](#section119744591305) -- [Usage](#section06487425716) - - [Available APIs](#section1551164914237) - - [Usage Guidelines](#section129654513264) +- [HiLog组件](#hilog组件) + - [简介](#简介) + - [目录](#目录) + - [约束](#约束) + - [说明](#说明) + - [接口说明](#接口说明) + - [使用说明](#使用说明) + - [涉及仓](#涉及仓) -- [Repositories Involved](#section177639411669) +- [涉及仓](#section177639411669) -## Introduction +## 简介 -HiLog is the module of OpenHarmony that logs information such as user operations and system running status for the system framework, services, and applications. +HiLog是OpenHarmony日志系统,提供给系统框架、服务、以及应用打印日志,记录用户操作、系统运行状态等。 -**Figure 1** Architecture of the HiLog module +**图 1** HiLog架构图 -![](figures/en-us_image_0000001115534242.png) +![](figures/zh-cn_image_0000001115534242.png) -User-space processes write logs to the ring buffer of hilogd through the log API. hilogd sends logs to the console for viewing or writes logs to the flash at the request of the hilog. +用户态Process通过日志接口将日志内容写入hilogd buffer中,用户态的hilog工具支持将输出到控制台(console)进行查看,同时也支持通过hilog工具给hilogd发送命令将日志落盘。 -The details are as follows: +下述主要任务的详细内容: -- **hilogd**: log service in the user space +- hilogd是流水日志的用户态服务。 -1. hilogd is a resident service and is enabled by default when the system is started. -2. User-space processes call the log APIs to transfer the formatted log content to hilogd and store the content in its ring buffer. +1. 此功能是常驻服务,在研发版本系统启动时默认启动。 +2. 当用户态模块调用日志接口,将格式化好的日志内容传输给该任务,并将其存储在一个环形缓冲区中 。 -- **hilog**: command line tool for viewing logs +- hilog日志查看命令行工具 -1. hilog reads the log content from the ring buffer of hilogd, filters the content if required, and then prints the content to the standard output. +1. 从hilogd读取ringbuffer内容,输出到标准输出,可支持日志过滤。 -Supported functions: +支持特性: -- Formatting of parameter privacy identifiers \(See the following example for details.\) -- Flow control on excess log processes -- Flow control on excess domains \(subsystems or modules\) involved in log printing -- Log compression and flushing +- 支持参数隐私标识格式化(详见下面举例)。 +- 支持对超标日志打印进程流控。 +- 支持对超标日志打印domain\(标识子系统/模块\)流控。 +- 支持流压缩落盘。 -## Directory Structure +## 目录 ``` /base/hiviewdfx/hilog -├── frameworks # Framework code -│ └── native # HiLog Native implementation code -├── interfaces # APIs -│ └── native # External C/C++ APIs -│ └── innerkits # Header files opened to internal subsystems -│ └── kits # Header files opened to applications +├── frameworks # 框架代码 +│ └── native # HiLog native实现代码 +├── interfaces # 接口 +│ └── native # 对外C/C++接口 +│ └── innerkits # 对内部子系统暴露的头文件 +│ └── kits # 对应用暴露的头文件 ├── services -│ └── hilogd # HiLog resident service implementation -│ └── hilogtool # HiLog tool implementation +│ └── hilogd # 日志常驻服务实现 +│ └── hilogtool # 日志工具实现 ``` -## Constraints +## 约束 -Clang 8.0.0 or later is required. +依赖 Clang 编译器\(**Clang** 8.0.0 \)及以上。 -## Usage +## 说明 -### Available APIs +### 接口说明 -**Table 1** Major APIs of HiLog +**表 1** 主要API说明 -

Class

+ - - @@ -76,49 +78,100 @@ Clang 8.0.0 or later is required. - -

Method

+

方法

Description

+

描述

HiLogLabel(int type, int domain, String tag)

Constructs a log label, including the log type, domain, and tag.

+

构造日志标签,包括:日志类型、领域标识、日志tag。

HiLog

Info(const HiLogLabel &label, const char *fmt, ...)

Prints logs of the info level.

+

info级别日志打印接口。

-### Usage Guidelines +### 使用说明 -1. View logs. +1. 查看日志 -Run the **hilog | grep "MY\_TAG"** command in shell mode. +通过shell , 执行命令 hilog | grep “MY\_TAG”。 ``` -Output in debug mode: +Debug模式输出: 01-26 11:01:06.870 1051 1051 W 00201/test: Failed to visit [https://gitee.com/openharmony](https://gitee.com/openharmony), reason:503. -Output in release mode: +release模式输出: 01-26 11:01:06.870 1051 1051 W 00201/test: Failed to visit , reason:503. ``` - -## Repositories Involved - -[DFX subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md) - -[hiviewdfx\_hiview](https://gitee.com/openharmony/hiviewdfx_hiview/blob/master/README.md) +2. hilog命令行使用说明 + + +| 短选项 | 长选项 | 参数 | 说明 | +|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|------------------|----------------------------------------------------------------------------------| +| -h | --help | | 帮助命令 | +| -x | --exit | | 非阻塞读日志,读完退出 | +| 缺省 | 缺省 | | 阻塞读日志,不退出 | +| -g | | | 查询buffer的大小,可配合-t使用,默认app和core | +| -G | --buffer-size=\ | | 设置指定日志类型缓冲区的大小,配合-t指定某一类型使用,默认app和core | +| -r | | | 清除buffer日志,配合-t指定某一类型使用,默认app和core | +| -p \, | --privacy=\ | | 支持系统调试时日志隐私开关控制,显示/明文 | +| -k\ | | | Kernel日志读取开关,是/否存储kernel日志 | +| -s | --statistics | | 查询统计信息,需配合-t或-D使用 | +| -S | | | 清除统计信息,需配合-t或-D使用 | +| -Q \ | | | 流控缺省配额开关控制 | +| | | pidon | 流控进程开关打开 | +| | | pidoff | 流控进程开关关闭 | +| | | domainon | 流控domain开关打开 | +| | | domainoff | 流控domain开关关闭 | +| -L \ | --level=\ | | 指定级别的日志,示例:-L D/I/W/E/F | +| -t \ | --type=\ | | 指定类型的日志,示例:-t app core init | +| -D \ | --domain=\ | | 指定domain | +| -T \ | --Tag=\ | | 指定tag | +| -a \ | --head=\ | | 只显示前\行日志 | +| -z \ | --tail=\ | | 只显示后\行日志 | +| -G \ | --buffer-size=\ | | 设置指定\日志类型缓冲区的大小,配合-t指定某一类型使用,默认app和core | +| -P \ | --pid =\ | | 标识不同的pid | +| -e \ | --regex=\ | | 只打印日志消息与\匹配的行,其中\是一个正则表达式 | +| -f \ | --filename=\ | | 设置落盘的文件名 | +| -l \ | --length=\ | | 设置落盘的文件大小,大于等于64K | +| -n \ | --number=\ | | 设置落盘文件的个数 | +| -j \ | --jobid=\ | | 设置落盘任务的ID | +| -w \ | --write=\ | | 落盘任务控制 | +| | | query | 落盘任务查询 | +| | | start | 落盘任务开始 | +| | | stop | 落盘任务停止 | +| -m \ | --stream=\ | | 落盘方式控制 | +| | | none | 无压缩方式落盘 | +| | | zlib | zlib压缩算法落盘,落盘文件为.gz | +| | | zstd | zstd压缩算法落盘,落盘文件为.zst | +|示例:hilog -w start -f "hilog" -l 66k -m zlib -n 10 | ||解释:执行名字为hilog的落盘任务,10个落盘文件进行轮转,单个文件落盘大小为66k,采用zlib压缩算法。 +| -v \ | --format=\ | | | +| | | time | 显示本地时间 | +| | | color | 显示不同级别显示不同颜色,参数缺省级别颜色模式处理(按黑白方式) | +| | | epoch | 显示相对1970时间 | +| | | monotonic | 显示相对启动时间 | +| | | usec | 显示微秒精度时间 | +| | | nsec | 显示纳秒精度时间 | +| | | year | 显示将年份添加到显示的时间 | +| | | zone | 显示将本地时区添加到显示的时间 | +| -b \ | --baselevel=\ | | 设置可存储日志的最低等级:D(DEBUG)/I(INFO)/W(WARN)/E(ERROR)/F(FATAL) | +## 涉及仓 + +[DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX%E5%AD%90%E7%B3%BB%E7%BB%9F.md) + +[hiviewdfx\_hiview](https://gitee.com/openharmony/hiviewdfx_hiview/blob/master/README_zh.md) **hiviewdfx\_hilog** -[hiviewdfx\_hiappevent](https://gitee.com/openharmony/hiviewdfx_hiappevent/blob/master/README.md) +[hiviewdfx\_hiappevent](https://gitee.com/openharmony/hiviewdfx_hiappevent/blob/master/README_zh.md) -[hiviewdfx\_hisysevent](https://gitee.com/openharmony/hiviewdfx_hisysevent/blob/master/README.md) +[hiviewdfx\_hisysevent](https://gitee.com/openharmony/hiviewdfx_hisysevent/blob/master/README_zh.md) -[hiviewdfx\_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md) +[hiviewdfx\_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README_zh.md) -[hiviewdfx\_hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README.md) +[hiviewdfx\_hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README_zh.md) -[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README.md) +[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README_zh.md) -[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README.md) +[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README_zh.md)