rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /*
|
| 2 | * Copyright Statement:
|
| 3 | *
|
| 4 | * This software/firmware and related documentation ("MediaTek Software") are
|
| 5 | * protected under relevant copyright laws. The information contained herein is
|
| 6 | * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
|
| 7 | * the prior written permission of MediaTek inc. and/or its licensors, any
|
| 8 | * reproduction, modification, use or disclosure of MediaTek Software, and
|
| 9 | * information contained herein, in whole or in part, shall be strictly
|
| 10 | * prohibited.
|
| 11 | *
|
| 12 | * MediaTek Inc. (C) 2017. All rights reserved.
|
| 13 | *
|
| 14 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
|
| 15 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
|
| 16 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
|
| 17 | * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
|
| 18 | * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
| 19 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
| 20 | * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
|
| 21 | * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
|
| 22 | * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
|
| 23 | * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
|
| 24 | * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
|
| 25 | * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
|
| 26 | * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
|
| 27 | * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
|
| 28 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
|
| 29 | * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
|
| 30 | * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
|
| 31 | * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
|
| 32 | * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
|
| 33 | */
|
| 34 | #ifndef LOG_H
|
| 35 | #define LOG_H
|
| 36 |
|
| 37 | #include <stdio.h>
|
| 38 |
|
| 39 | extern int log_dbg_level;
|
| 40 |
|
| 41 | #define LOG_IS_ENABLED(level) \
|
| 42 | (log_dbg_level >= level)
|
| 43 |
|
| 44 | unsigned int get_time(void);
|
| 45 | int set_log_level(int fg_enable, int level);
|
| 46 | int get_log_level();
|
| 47 |
|
| 48 | #ifndef gettid
|
| 49 | #include <unistd.h>
|
| 50 | #include <sys/syscall.h>
|
| 51 | #define gettid() syscall(__NR_gettid)
|
| 52 | #endif
|
| 53 |
|
| 54 | #define PRINT_LOG(loglevel, tag, fmt, args...) \
|
| 55 | do {\
|
| 56 | if (LOG_IS_ENABLED(loglevel)) {\
|
| 57 | printf(tag " %d " fmt "\n",\
|
| 58 | __LINE__, ##args);\
|
| 59 | fflush(stdout);\
|
| 60 | }\
|
| 61 | } while (0)
|
| 62 |
|
| 63 | #define LOG_ERROR(fmt, args...) PRINT_LOG(1, "[ERROR]: ", fmt, ##args)
|
| 64 | #define LOG_TEST_INFO(fmt, args...) PRINT_LOG(1, "[TEST_INFO]: ", fmt, ##args)
|
| 65 | #define LOG_WARN(fmt, args...) PRINT_LOG(2, "[WARNING]: ", fmt, ##args)
|
| 66 | #define LOG_INFO(fmt, args...) PRINT_LOG(3, "[INFO]: ", fmt, ##args)
|
| 67 | #define LOG_DEBUG(fmt, args...) PRINT_LOG(4, "[DEBUG]: ", fmt, ##args)
|
| 68 |
|
| 69 | #endif
|