1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CGROUP_SCHED_FRAMEWORK_PROCESS_GROUP_INCLUDE_PROCESS_GROUP_LOG_H_
17 #define CGROUP_SCHED_FRAMEWORK_PROCESS_GROUP_INCLUDE_PROCESS_GROUP_LOG_H_
18 
19 #include "hilog/log_c.h"    // for LogLevel, LOG_CORE, LOG_LEVEL_MAX, LOG_LE...
20 #include "hilog/log_cpp.h"  // for HiLogLabel
21 
22 #undef LOG_DOMAIN
23 #define LOG_DOMAIN 0xD001702
24 
25 #undef LOG_TAG
26 #define LOG_TAG "pg-cgs"
27 
28 #define PGCGS_LOGD(...) HILOG_DEBUG(LOG_CORE, __VA_ARGS__)
29 #define PGCGS_LOGI(...) HILOG_INFO(LOG_CORE, __VA_ARGS__)
30 #define PGCGS_LOGW(...) HILOG_WARN(LOG_CORE, __VA_ARGS__)
31 #define PGCGS_LOGE(...) HILOG_ERROR(LOG_CORE, __VA_ARGS__)
32 #define PGCGS_LOGF(...) HILOG_FATAL(LOG_CORE, __VA_ARGS__)
33 
34 namespace OHOS {
35 namespace ResourceSchedule {
36 namespace CgroupSetting {
37 class ProcessGroupLog {
38 public:
39     ProcessGroupLog() = delete;
40     ~ProcessGroupLog() = delete;
41 
42     /**
43      * @brief Judge level.
44      *
45      * @param level The level.
46      * @return True if success,else false.
47      */
48     static bool JudgeLevel(const LogLevel &level);
49 
50     /**
51      * @brief Get log level.
52      *
53      * @return Level.
54      */
GetLogLevel()55     static const LogLevel &GetLogLevel()
56     {
57         return level_;
58     }
59 
60 private:
61     static LogLevel level_;
62 };
63 } // namespace CgroupSetting
64 } // namespace ResourceSchedule
65 } // namespace OHOS
66 #endif // CGROUP_SCHED_FRAMEWORK_PROCESS_GROUP_INCLUDE_PROCESS_GROUP_LOG_H_
67