2 Star 0 Fork 102

OpenHarmony_EU incubator/hiviewdfx_utils_lite

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hiview_config.c 2.55 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* 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 "hos_types.h"
#include "hos_init.h"
#include "hiview_log.h"
#include "hiview_config.h"
#include <stdint.h>
HiviewConfig g_hiviewConfig = {
.outputOption = OUTPUT_OPTION_FLOW,
.level = HILOG_LV_DEBUG,
.logSwitch = HIVIEW_FEATURE_ON,
.dumpSwitch = HIVIEW_FEATURE_OFF,
.eventSwitch = HIVIEW_FEATURE_OFF,
};
static void HiviewConfigInit(void)
{
g_hiviewConfig.hiviewInited = FALSE;
g_hiviewConfig.logOutputModule = UINT64_MAX;
g_hiviewConfig.writeFailureCount = 0;
}
CORE_INIT_PRI(HiviewConfigInit, 0);
boolean SetLogLevel(uint8 level)
{
if (level >= HILOG_LV_DEBUG && level < HILOG_MODULE_MAX) {
g_hiviewConfig.level = level;
return TRUE;
}
return FALSE;
}
void SwitchLog(uint8 flag)
{
(flag == HIVIEW_FEATURE_ON) ? (g_hiviewConfig.logSwitch = HIVIEW_FEATURE_ON) :
(g_hiviewConfig.logSwitch = HIVIEW_FEATURE_OFF);
}
void SwitchEvent(uint8 flag)
{
(flag == HIVIEW_FEATURE_ON) ? (g_hiviewConfig.eventSwitch = HIVIEW_FEATURE_ON) :
(g_hiviewConfig.eventSwitch = HIVIEW_FEATURE_OFF);
}
void SwitchDump(uint8 flag)
{
(flag == HIVIEW_FEATURE_ON) ? (g_hiviewConfig.dumpSwitch = HIVIEW_FEATURE_ON) :
(g_hiviewConfig.dumpSwitch = HIVIEW_FEATURE_OFF);
}
boolean OpenLogOutputModule(uint8 mod)
{
if (mod < HILOG_MODULE_MAX) {
g_hiviewConfig.logOutputModule |= (1 << mod);
return TRUE;
}
return FALSE;
}
boolean CloseLogOutputModule(uint8 mod)
{
if (mod < HILOG_MODULE_MAX) {
g_hiviewConfig.logOutputModule &= (~(1 << mod));
return TRUE;
}
return FALSE;
}
boolean SetLogOutputModule(uint8 mod)
{
if (mod < HILOG_MODULE_MAX) {
g_hiviewConfig.logOutputModule &= (1 << mod);
return TRUE;
} else if (mod == HILOG_MODULE_MAX) {
g_hiviewConfig.logOutputModule = UINT64_MAX;
return TRUE;
} else {
return FALSE;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/open-harmony-eu-incubator/hiviewdfx_utils_lite.git
git@gitee.com:open-harmony-eu-incubator/hiviewdfx_utils_lite.git
open-harmony-eu-incubator
hiviewdfx_utils_lite
hiviewdfx_utils_lite
master

搜索帮助