1 /*
2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 #include <iot_log.h>
17
18 static EnIotLogLevelT g_ioTLogLevel = EN_IOT_LOG_LEVEL_TRACE;
19 static const char *g_ioTLogLevelNames[] = {
20 "TRACE",
21 "DEBUG",
22 "INFO ",
23 "WARN ",
24 "ERROR",
25 "FATAL"
26 };
27
IoTLogLevelSet(EnIotLogLevelT level)28 int IoTLogLevelSet(EnIotLogLevelT level)
29 {
30 int ret = -1;
31 if (level < EN_IOT_LOG_LEVEL_MAX) {
32 g_ioTLogLevel = level;
33 ret = 0;
34 }
35 return ret;
36 }
37
IoTLogLevelGet(void)38 EnIotLogLevelT IoTLogLevelGet(void)
39 {
40 return g_ioTLogLevel;
41 }
42
IoTLogLevelGetName(EnIotLogLevelT logLevel)43 const char *IoTLogLevelGetName(EnIotLogLevelT logLevel)
44 {
45 if (logLevel >= EN_IOT_LOG_LEVEL_MAX) {
46 return "NULL ";
47 } else {
48 return g_ioTLogLevelNames[logLevel];
49 }
50 }