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 HILOG_COMMON_H 17 #define HILOG_COMMON_H 18 19 #include <stdint.h> 20 #include <stddef.h> 21 22 #define SOCKET_FILE_DIR "/dev/unix/socket/" 23 #define INPUT_SOCKET_NAME "hilogInput" 24 25 #define MAX_LOG_LEN 1024 /* maximum length of a log, include '\0' */ 26 #define MAX_TAG_LEN 32 /* log tag size, include '\0' */ 27 28 /* 29 * header of log message from libhilog to hilogd 30 */ 31 typedef struct __attribute__((__packed__)) { 32 uint16_t len; 33 uint16_t version : 3; 34 uint16_t type : 4; /* APP,CORE,INIT,SEC etc */ 35 uint16_t level : 3; 36 uint16_t tag_len : 6; /* include '\0' */ 37 uint32_t tv_sec; 38 uint32_t tv_nsec; 39 uint32_t mono_sec; 40 uint32_t pid; 41 uint32_t tid; 42 uint32_t domain; 43 char tag[]; /* shall be end with '\0' */ 44 } HilogMsg; 45 46 #if defined(__GNUC__) && (__GNUC__ >= 4) 47 #define HILOG_PUBLIC_API __attribute__((visibility("default"))) 48 #define HILOG_LOCAL_API __attribute__((visibility("hidden"))) 49 #else 50 #define HILOG_PUBLIC_API 51 #define HILOG_LOCAL_API 52 #endif 53 54 #endif /* HILOG_COMMON_H */ 55