69 lines
2.5 KiB
C
69 lines
2.5 KiB
C
/*
|
|
* Copyright (C) 2010 Amlogic Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
|
|
#ifndef _AML_LOG_H_
|
|
#define _AML_LOG_H_
|
|
|
|
#ifdef ANDROID_BUILD
|
|
#include <android/log.h>
|
|
#include <stdio.h>
|
|
|
|
#ifdef USE_LOGCAT
|
|
#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
|
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
|
#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
|
|
#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
|
#else
|
|
#include <time.h>
|
|
#include <sys/time.h>
|
|
|
|
#define aml_print(fmt, ...) \
|
|
do { \
|
|
struct timespec ts; \
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &ts); \
|
|
printf("[%lld.%09ld]" fmt "\n",(long long)ts.tv_sec, ts.tv_nsec, ##__VA_ARGS__); \
|
|
} while(0)
|
|
|
|
#define ALOGD(fmt, ...) aml_print(fmt, ##__VA_ARGS__)
|
|
#define ALOGI(fmt, ...) aml_print(fmt, ##__VA_ARGS__)
|
|
#define ALOGW(fmt, ...) aml_print(fmt, ##__VA_ARGS__)
|
|
#define ALOGE(fmt, ...) aml_print(fmt, ##__VA_ARGS__)
|
|
#endif
|
|
#define ALOGV(...) ((void)0)
|
|
#define ALOG_ASSERT(...) ((void)0)
|
|
#define LOG_ALWAYS_FATAL_IF(...) ((void)0)
|
|
#define LOG_ALWAYS_FATAL(...) ((void)0)
|
|
#define LOG_FATAL_IF(...) ((void)0)
|
|
#define ALOGW_IF(...) ((void)0)
|
|
#define ALOGI_IF(...) ((void)0)
|
|
#define ALOGD_IF(...) ((void)0)
|
|
#else
|
|
#include <cutils/log.h>
|
|
#endif
|
|
|
|
|
|
#define AM_LOGV(fmt, ...) ALOGV("[%s:%d] " fmt, __func__,__LINE__, ##__VA_ARGS__)
|
|
#define AM_LOGD(fmt, ...) ALOGD("[%s:%d] " fmt, __func__,__LINE__, ##__VA_ARGS__)
|
|
#define AM_LOGI(fmt, ...) ALOGI("[%s:%d] " fmt, __func__,__LINE__, ##__VA_ARGS__)
|
|
#define AM_LOGW(fmt, ...) ALOGW("[%s:%d] " fmt, __func__,__LINE__, ##__VA_ARGS__)
|
|
#define AM_LOGE(fmt, ...) ALOGE("[%s:%d] " fmt, __func__,__LINE__, ##__VA_ARGS__)
|
|
#define AM_LOGI_IF(cond, fmt, ...) \
|
|
if(cond) { \
|
|
AM_LOGI(fmt, ##__VA_ARGS__); \
|
|
}
|
|
#endif
|