feat: add basic logging interface
Introduce a lightweight logger interface, allowing clients to register
custom info, warn, and error handlers. Adds initial integration into
transfer_list.h.
Change-Id: Ia2470ce58566385f3c7df068f600d236c09625ca
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
diff --git a/include/logging.h b/include/logging.h
new file mode 100644
index 0000000..fdfb2cd
--- /dev/null
+++ b/include/logging.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright The Transfer List Library Contributors
+ *
+ * SPDX-License-Identifier: MIT OR GPL-2.0-or-later
+ */
+
+#ifndef LOGGING_H
+#define LOGGING_H
+
+struct logger_interface {
+ void (*info)(const char *fmt, ...);
+ void (*warn)(const char *fmt, ...);
+ void (*error)(const char *fmt, ...);
+};
+
+extern struct logger_interface *logger;
+
+#define info(...) \
+ do { \
+ if (logger && logger->info) \
+ logger->info(__VA_ARGS__); \
+ } while (0)
+
+#define warn(...) \
+ do { \
+ if (logger && logger->warn) \
+ logger->warn(__VA_ARGS__); \
+ } while (0)
+
+#define error(...) \
+ do { \
+ if (logger && logger->error) \
+ logger->error(__VA_ARGS__); \
+ } while (0)
+
+void libtl_register_logger(struct logger_interface *user_logger);
+
+#endif