10a7ce71fSopenharmony_ci/*
20a7ce71fSopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
30a7ce71fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40a7ce71fSopenharmony_ci * you may not use this file except in compliance with the License.
50a7ce71fSopenharmony_ci * You may obtain a copy of the License at
60a7ce71fSopenharmony_ci *
70a7ce71fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80a7ce71fSopenharmony_ci *
90a7ce71fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100a7ce71fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110a7ce71fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120a7ce71fSopenharmony_ci * See the License for the specific language governing permissions and
130a7ce71fSopenharmony_ci * limitations under the License.
140a7ce71fSopenharmony_ci */
150a7ce71fSopenharmony_ci
160a7ce71fSopenharmony_ci#include <iot_log.h>
170a7ce71fSopenharmony_ci
180a7ce71fSopenharmony_cistatic EnIotLogLevel gIoTLogLevel = EN_IOT_LOG_LEVEL_TRACE;
190a7ce71fSopenharmony_cistatic const char *gIoTLogLevelNames[] = {
200a7ce71fSopenharmony_ci    "TRACE",
210a7ce71fSopenharmony_ci    "DEBUG",
220a7ce71fSopenharmony_ci    "INFO ",
230a7ce71fSopenharmony_ci    "WARN ",
240a7ce71fSopenharmony_ci    "ERROR",
250a7ce71fSopenharmony_ci    "FATAL"
260a7ce71fSopenharmony_ci};
270a7ce71fSopenharmony_ci
280a7ce71fSopenharmony_ciint IoTLogLevelSet(EnIotLogLevel level)
290a7ce71fSopenharmony_ci{
300a7ce71fSopenharmony_ci    int ret = -1;
310a7ce71fSopenharmony_ci    if (level < EN_IOT_LOG_LEVEL_MAX) {
320a7ce71fSopenharmony_ci        gIoTLogLevel = level;
330a7ce71fSopenharmony_ci        ret = 0;
340a7ce71fSopenharmony_ci    }
350a7ce71fSopenharmony_ci    return ret;
360a7ce71fSopenharmony_ci}
370a7ce71fSopenharmony_ci
380a7ce71fSopenharmony_ciEnIotLogLevel IoTLogLevelGet(void)
390a7ce71fSopenharmony_ci{
400a7ce71fSopenharmony_ci    return gIoTLogLevel;
410a7ce71fSopenharmony_ci}
420a7ce71fSopenharmony_ci
430a7ce71fSopenharmony_ciconst char *IoTLogLevelGetName(EnIotLogLevel logLevel)
440a7ce71fSopenharmony_ci{
450a7ce71fSopenharmony_ci    if (logLevel >= EN_IOT_LOG_LEVEL_MAX) {
460a7ce71fSopenharmony_ci        return "NULL ";
470a7ce71fSopenharmony_ci    } else {
480a7ce71fSopenharmony_ci        return gIoTLogLevelNames[logLevel];
490a7ce71fSopenharmony_ci    }
500a7ce71fSopenharmony_ci}
51