1/******************************************************************************
2 *
3 *  Copyright (C) 2014 Google, Inc.
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19#pragma once
20
21/*
22 * TODO(armansito): Work-around until we figure out a way to generate logs in a
23 * platform-independent manner.
24 */
25#if defined(OS_GENERIC)
26
27/* syslog didn't work well here since we would be redefining LOG_DEBUG. */
28#include <stdio.h>
29
30#define LOGWRAPPER(tag, fmt, args...) fprintf(stderr, "%s: " fmt "\n", tag, ## args)
31
32#define LOG_VERBOSE(...) LOGWRAPPER(__VA_ARGS__)
33#define LOG_DEBUG(...) LOGWRAPPER(__VA_ARGS__)
34#define LOG_INFO(...) LOGWRAPPER(__VA_ARGS__)
35#define LOG_WARN(...) LOGWRAPPER(__VA_ARGS__)
36#define LOG_ERROR(...) LOGWRAPPER(__VA_ARGS__)
37
38#else  /* !defined(OS_GENERIC) */
39
40#include <cutils/log.h>
41
42#if LOG_NDEBUG
43#define LOG_VERBOSE(...) ((void)0)
44#else  // LOG_NDEBUG
45#define LOG_VERBOSE(tag, fmt, args...) ALOG(LOG_VERBOSE, tag, fmt, ## args)
46#endif  // !LOG_NDEBUG
47#define LOG_DEBUG(tag, fmt, args...)   ALOG(LOG_DEBUG, tag, fmt, ## args )
48#define LOG_INFO(tag, fmt, args...)    ALOG(LOG_INFO, tag, fmt, ## args)
49#define LOG_WARN(tag, fmt, args...)    ALOG(LOG_WARN, tag, fmt, ## args)
50#define LOG_ERROR(tag, fmt, args...)   ALOG(LOG_ERROR, tag, fmt, ## args)
51
52#endif  /* defined(OS_GENERIC) */
53