summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Borges <paulo.borges@openbossa.org>2013-11-26 23:24:23 -0300
committerPaulo Borges <paulo.borges@openbossa.org>2013-12-22 22:43:06 -0300
commit61065da10cd2cb8c3a27f1ee687a802acf48d2fc (patch)
tree7592e25b6ed27d8cc89fc5f52a3cbda7136e6ff2
parenta05ab49cc4b92fbe62f0ba1eb0c75e8971c0a4dc (diff)
log: Add log interface
This patch adds the interface which every platform should implement to have logging capabilities.
-rw-r--r--stack/log.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/stack/log.h b/stack/log.h
new file mode 100644
index 0000000..4ffa75f
--- /dev/null
+++ b/stack/log.h
@@ -0,0 +1,41 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013 Paulo B. de Oliveira Filho <pauloborgesfilho@gmail.com>
+ * Copyright (c) 2013 Claudio Takahasi <claudio.takahasi@gmail.com>
+ * Copyright (c) 2013 João Paulo Rechi Vita <jprvita@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+int16_t log_init(void);
+void log_print(const char *format, ...);
+
+#define __ONLYFILE__ \
+ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+
+#define LOG(level, fmt, arg...) \
+ do { \
+ log_print(level ":%s:%s() " fmt "\r\n", \
+ __ONLYFILE__, __func__, ## arg); \
+ } while (0)
+
+#define DBG(fmt, arg...) LOG("DEBUG", fmt, ## arg)
+
+#define ERROR(fmt, arg...) LOG("ERROR", fmt, ## arg)