1/* 2 * Copyright (c) 2022-2023 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#ifndef DFX_MUSL_LOG_H 16#define DFX_MUSL_LOG_H 17 18#include <inttypes.h> 19#include <stdarg.h> 20#include <stddef.h> 21 22#include "dfx_log_define.h" 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28#ifdef ENABLE_SIGHAND_MUSL_LOG 29 30/* Log type */ 31typedef enum { 32 /* min log type */ 33 LOG_TYPE_MIN = 0, 34 /* Used by app log. */ 35 LOG_APP = 0, 36 /* Log to kmsg, only used by init phase. */ 37 LOG_INIT = 1, 38 /* Used by core service, framework. */ 39 LOG_CORE = 3, 40 /* Used by kmsg log. */ 41 LOG_KMSG = 4, 42 /* max log type */ 43 LOG_TYPE_MAX 44} LogType; 45 46/* Log level */ 47typedef enum { 48 /* min log level */ 49 LOG_LEVEL_MIN = 0, 50 /* Designates lower priority log. */ 51 LOG_DEBUG = 3, 52 /* Designates useful information. */ 53 LOG_INFO = 4, 54 /* Designates hazardous situations. */ 55 LOG_WARN = 5, 56 /* Designates very serious errors. */ 57 LOG_ERROR = 6, 58 /* Designates major fatal anomaly. */ 59 LOG_FATAL = 7, 60 /* max log level */ 61 LOG_LEVEL_MAX, 62} LogLevel; 63 64__attribute__ ((visibility("hidden"))) int MuslHiLogPrinter( 65 LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...); 66 67// replace the old interface, and delete the old interface after the replacement is complete 68#define DFXMUSL_PRINT(prio, ...) MuslHiLogPrinter(LOG_CORE, prio, LOG_DOMAIN, LOG_TAG, __VA_ARGS__) 69 70#define DFXLOGD(...) DFXMUSL_PRINT(LOG_DEBUG, __VA_ARGS__) 71#define DFXLOGI(...) DFXMUSL_PRINT(LOG_INFO, __VA_ARGS__) 72#define DFXLOGW(...) DFXMUSL_PRINT(LOG_WARN, __VA_ARGS__) 73#define DFXLOGE(...) DFXMUSL_PRINT(LOG_ERROR, __VA_ARGS__) 74#define DFXLOGF(...) DFXMUSL_PRINT(LOG_FATAL, __VA_ARGS__) 75 76#else 77 78// replace the old interface, and delete the old interface after the replacement is complete 79#define DFXLOGD(...) 80#define DFXLOGI(...) 81#define DFXLOGW(...) 82#define DFXLOGE(...) 83#define DFXLOGF(...) 84 85#endif 86 87#ifdef __cplusplus 88} 89#endif 90#endif