blob: 4f1b9eefcae1630a60a9a173808a93f41a8f3a99 [file] [log] [blame]
leng.fang07ca08d2023-05-08 07:33:53 +00001/*
2 * Copyright (c) 2017 Amlogic, Inc. All rights reserved.
3 *
4 * This source code is subject to the terms and conditions defined in the
5 * file 'LICENSE' which is part of this source code package.
6 *
7 * Description:
8 */
9
10#ifndef MESON_LOG_H
11#define MESON_LOG_H
12
13#ifndef LOG_TAG
14#define LOG_TAG "UVM"
15#endif
16
17#include <unistd.h>
18#include <stdlib.h>
19#include <string.h>
20
21#ifdef UVM_RELEASE
22#define MESON_DEBUG_LEVEL 0
23#else
24#define MESON_DEBUG_LEVEL 1
25#endif
26
27#define ALOGV(fmt, ...) fprintf(stderr, "[V] %s: " fmt "\n", LOG_TAG, ##__VA_ARGS__)
28#define ALOGD(fmt, ...) fprintf(stderr, "[D] %s: " fmt "\n", LOG_TAG, ##__VA_ARGS__)
29#define ALOGI(fmt, ...) fprintf(stderr, "[I] %s: " fmt "\n", LOG_TAG, ##__VA_ARGS__)
30#define ALOGW(fmt, ...) fprintf(stderr, "[W] %s: " fmt "\n", LOG_TAG, ##__VA_ARGS__)
31#define ALOGE(fmt, ...) fprintf(stderr, "[E] %s: " fmt "\n", LOG_TAG, ##__VA_ARGS__)
32
33#if MESON_DEBUG_LEVEL > 0
34#define MESON_LOGV(fmt,...) ALOGV(fmt, ##__VA_ARGS__)
35#define MESON_LOGD(fmt,...) ALOGD(fmt, ##__VA_ARGS__)
36#define MESON_LOGI(fmt,...) ALOGI(fmt, ##__VA_ARGS__)
37#define MESON_LOGW(fmt,...) ALOGW(fmt, ##__VA_ARGS__)
38#else
39#define MESON_LOGV(fmt,...) ((void)0)
40#define MESON_LOGD(fmt,...) ((void)0)
41#define MESON_LOGI(fmt,...) ((void)0)
42#define MESON_LOGW(fmt,...) ((void)0)
43#endif
44#define MESON_LOGE(fmt,...) ALOGE(fmt, ##__VA_ARGS__)
45
46#if MESON_DEBUG_LEVEL > 0
47#define MESON_ASSERT(condition,fmt,...) \
48 if (!(condition)) { \
49 ALOGE(fmt, ##__VA_ARGS__); \
50 abort(); \
51 }
52#else
53#define MESON_ASSERT(condition,fmt,...) \
54 if (!(condition)) { \
55 ALOGE(fmt, ##__VA_ARGS__); \
56 }
57#endif
58
59#if MESON_DEBUG_LEVEL > 2
60#define MESON_LOG_FUN_ENTER() ALOGV("Enter %s", __func__)
61#define MESON_LOG_FUN_LEAVE() ALOGV("Leave %s", __func__)
62#else
63#define MESON_LOG_FUN_ENTER() ((void)0)
64#define MESON_LOG_FUN_LEAVE() ((void)0)
65#endif
66
67#define MESON_LOG_EMPTY_FUN() \
68 ALOGD("ERR: PLEASE FIX NON-IMPLEMENT FUN(%s).", __func__);
69
70#endif/*MESON_LOG_H*/