1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to 6 * deal in the Software without restriction, including without limitation the 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 * sell copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 * IN THE SOFTWARE. 21 */ 22 23 #ifndef MUSL_HILOG_ADAPTER_H 24 #define MUSL_HILOG_ADAPTER_H 25 26 #include <features.h> 27 #include <stdarg.h> 28 #include <stdbool.h> 29 30 #ifndef hidden 31 #define hidden __attribute__((visibility("hidden"))) 32 #endif 33 34 // Log type 35 typedef enum { 36 LOG_TYPE_MIN = 0, 37 LOG_APP = 0, 38 // Log to kmsg, only used by init phase. 39 LOG_INIT = 1, 40 // Used by core service, framework. 41 LOG_CORE = 3, 42 LOG_KMSG = 4, 43 LOG_TYPE_MAX 44 } LogType; 45 46 // Log level 47 typedef enum { 48 LOG_LEVEL_MIN = 0, 49 LOG_DEBUG = 3, 50 LOG_INFO = 4, 51 LOG_WARN = 5, 52 LOG_ERROR = 6, 53 LOG_FATAL = 7, 54 LOG_LEVEL_MAX = 8, 55 } LogLevel; 56 57 hidden bool CheckHilogValid(); 58 // Dangerous operation, please do not use in normal business 59 hidden void RefreshHiLogSocketFd(); 60 61 hidden void InitHilogSocketFd(); 62 63 hidden int HiLogAdapterPrint(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) 64 __attribute__((__format__(os_log, 5, 6))); 65 66 hidden int HiLogAdapterPrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, 67 const char *fmt, va_list ap); 68 hidden int HiLogAdapterVaList(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, 69 va_list ap); 70 71 hidden bool HiLogAdapterIsLoggable(unsigned int domain, const char *tag, LogLevel level); 72 73 #ifdef OHOS_ENABLE_PARAMETER 74 #include "sys_param.h" 75 hidden bool get_bool_sysparam(CachedHandle cachedhandle); 76 #endif 77 78 hidden bool is_musl_log_enable(); 79 hidden void musl_log_reset(); 80 81 #endif // MUSL_HILOG_ADAPTER_H 82