summaryrefslogtreecommitdiff
path: root/android/hal-log.h
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2013-10-20 19:45:41 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-20 22:37:59 +0300
commit7d07e65034082f4921475ed045b045f92162ab30 (patch)
tree3b9552a626598b0074eb0716f5c6132c60a729ac /android/hal-log.h
parent12405f10d56dd4e0adb3c8e3d464abf1e8e74f00 (diff)
downloadbluez-7d07e65034082f4921475ed045b045f92162ab30.tar.gz
android: Add wrapper for HAL logging
Provide logging API similar to standard logging used in daemon. This will allow to log on both Android and Linux (i.e. in haltest). Another advantage is that now LOG_TAG and message format are configured from single location.
Diffstat (limited to 'android/hal-log.h')
-rw-r--r--android/hal-log.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/android/hal-log.h b/android/hal-log.h
new file mode 100644
index 000000000..9bd024d8c
--- /dev/null
+++ b/android/hal-log.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2013 Intel 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.
+ *
+ */
+
+#define LOG_TAG "BlueZ"
+
+#ifdef __BIONIC__
+#include <cutils/log.h>
+#else
+#include <stdio.h>
+#define LOG_INFO " I"
+#define LOG_WARN " W"
+#define LOG_ERROR " E"
+#define LOG_DEBUG " D"
+#define ALOG(pri, tag, fmt, arg...) printf(tag pri": " fmt"\n", ##arg)
+#endif
+
+#define info(fmt, arg...) ALOG(LOG_INFO, LOG_TAG, fmt, ##arg)
+#define warn(fmt, arg...) ALOG(LOG_WARN, LOG_TAG, fmt, ##arg)
+#define error(fmt, arg...) ALOG(LOG_ERROR, LOG_TAG, fmt, ##arg)
+#define DBG(fmt, arg...) ALOG(LOG_DEBUG, LOG_TAG, "%s:%s() "fmt, __FILE__, \
+ __func__, ##arg)