Description:fix issue from internal review

Change-Id: I3b5a4e143e54fe88899564edf7c663533150a3d6
Signed-off-by: shenchenkai <shenchenkai@huawei.com>
This commit is contained in:
shenchenkai
2022-03-09 11:45:58 +08:00
parent c60f6227fd
commit 691c8dcb39
24 changed files with 41 additions and 20 deletions
Executable → Regular
View File
+4 -4
View File
@@ -67,7 +67,7 @@ The overall code of the mini system is developed based on the C standard library
## Log Function for the Mini System<a name="sd6e99f792bc942f9bb5aa92111be7aff"></a>
- To add a module \(for example, Module A\) and print logs, perform the following steps:
1. **Add the module ID. **
1. **Add the module ID.**
Add **HILOG\_MODULE\_A** to **base/hiviewdfx/interfaces/hilog\_lite/interfaces/native/kits/hilog\_lite**.
@@ -296,8 +296,8 @@ Parameter description
[DFX subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md)
**hiviwdfx\_hilog\_lite**
**hiviewdfx\_hilog\_lite**
[hiviwdfx\_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.md)
[hiviwdfx\_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.md)
+4 -4
View File
@@ -148,7 +148,7 @@
## 使用-小型系统<a name="s33e0a62bc1dd4a2a9578fc22bd023f11"></a>
**Native C/C++**接口
**Native C/C++接口**
hilog 可用API
@@ -250,8 +250,8 @@ HILOG_FATAL(type, ...)
[DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
**hiviwdfx\_hilog\_lite**
**hiviewdfx\_hilog\_lite**
[hiviwdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README_zh.md)
[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README_zh.md)
[hiviwdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README_zh.md)
[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README_zh.md)
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
+1
View File
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := hilog
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
View File
Executable → Regular
+2 -2
View File
@@ -64,8 +64,8 @@ CORE_INIT_PRI(HiLogInit, 0);
static boolean CheckParameters(uint8 module, uint8 level)
{
if ((level < g_hiviewConfig.level) || (level < HILOG_COMPILE_LEVEL)
|| (module >= HILOG_MODULE_MAX) || (g_logModuleInfo[module].name == NULL)) {
if ((level < g_hiviewConfig.level) || (level < HILOG_COMPILE_LEVEL) ||
(module >= HILOG_MODULE_MAX) || (g_logModuleInfo[module].name == NULL)) {
return FALSE;
}
+1 -1
View File
@@ -115,7 +115,7 @@ void SetLimitThreshold(uint8 module, uint8 v)
const HiLogLimitRule *GetLogLimitRule(uint8 module)
{
if (module >= HILOG_MODULE_MAX) {
if (module >= HILOG_MODULE_MAX || g_hilogLimitList == NULL) {
return NULL;
}
return g_hilogLimitList + module;
View File
+1 -4
View File
@@ -513,10 +513,7 @@ static int32 LogDebugValuesFmt(char *desStrPtr, int32 desLen, const HiLogContent
break;
}
if (ret < 0) {
ret = 0;
}
return ret;
return (ret < 0) ? 0 : ret;
}
static int32 LogValuesFmtHash(char *desStrPtr, int32 desLen, const HiLogContent *logContentPtr)
View File
View File
View File
View File
View File
View File
View File
Executable → Regular
+1
View File
@@ -55,6 +55,7 @@ static_library("apphilogcat_static") {
deps = [
"//base/hiviewdfx/hilog_lite/command:hilog_command_static",
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
"//third_party/bounds_checking_function:libsec_shared",
]
public_configs = [ ":apphilogcat_config" ]
+18 -4
View File
@@ -15,6 +15,7 @@
#include <errno.h>
#include <fcntl.h>
#include <securec.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -57,7 +58,9 @@ static int FileSize(const char *filename)
static FILE *FileClear(FILE **fp, const char *filename)
{
fclose(*fp);
if (*fp != NULL) {
fclose(*fp);
}
*fp = fopen(filename, "w");
if (*fp == NULL) {
return NULL;
@@ -134,8 +137,8 @@ static void FileClose(FILE *file)
int main(int argc, char *argv[])
{
#define HILOG_UMASK 0027
int fd;
int ret;
int fd = -1;
int ret = -1;
FILE *fpWrite = NULL;
bool printFlag = true;
@@ -176,8 +179,15 @@ int main(int argc, char *argv[])
FileClose(fp2);
return 0;
}
char *buf = malloc(HILOG_LOGBUFFER + 1);
if (buf == NULL) {
close(fd);
FileClose(fp1);
FileClose(fp2);
return 0;
}
while (1) {
char buf[HILOG_LOGBUFFER + 1] = {0};
(void)memset_s(buf, HILOG_LOGBUFFER + 1, 0, HILOG_LOGBUFFER + 1);
ret = read(fd, buf, HILOG_LOGBUFFER);
if (ret < sizeof(struct HiLogEntry)) {
continue;
@@ -244,5 +254,9 @@ int main(int argc, char *argv[])
return 0;
}
}
free(buf);
close(fd);
FileClose(fp1);
FileClose(fp2);
return 0;
}
Executable → Regular
View File
+9 -1
View File
@@ -14,6 +14,7 @@
*/
#include <fcntl.h>
#include <securec.h>
#include <unistd.h>
#include <time.h>
@@ -40,8 +41,13 @@ int main(int argc, char *argv[])
HILOG_ERROR(LOG_CORE, "open hilog driver failed\n");
return 0;
}
char *buf = malloc(HILOG_LOGBUFFER);
if (buf == NULL) {
close(fd);
return 0;
}
while (1) {
char buf[HILOG_LOGBUFFER] = {0};
(void)memset_s(buf, HILOG_LOGBUFFER, 0, HILOG_LOGBUFFER);
ret = read(fd, buf, HILOG_LOGBUFFER);
if (ret < sizeof(struct HiLogEntry)) {
continue;
@@ -72,5 +78,7 @@ int main(int argc, char *argv[])
printf("%02d-%02d %02d:%02d:%02d.%03d %d %d %s\n", info->tm_mon + 1, info->tm_mday, info->tm_hour, info->tm_min,
info->tm_sec, head->nsec / NANOSEC_PER_MIRCOSEC, head->pid, head->taskId, head->msg);
}
free(buf);
close(fd);
return 0;
}