Logger: Use libosmocore logging system

We still need an intermediate class Logger due to osmo-trx being
multi-threaded and requiring to have a lock to use libosmocore, which is
not thread safe.

Change-Id: I30baac89f53e927f8699d0586b43cccf88ecd493
diff --git a/tests/CommonLibs/LogTest.cpp b/tests/CommonLibs/LogTest.cpp
index 707e26c..b8677e6 100644
--- a/tests/CommonLibs/LogTest.cpp
+++ b/tests/CommonLibs/LogTest.cpp
@@ -28,21 +28,37 @@
 #include <iterator>
 
 #include "Logger.h"
+extern "C" {
+#include <osmocom/core/application.h>
+#include <osmocom/core/utils.h>
+#include "debug.h"
+}
+
+#define MYCAT 0
 
 int main(int argc, char *argv[])
 {
-	gLogInit("NOTICE");
+	struct log_info_cat categories[1];
+	struct log_info linfo;
+	categories[MYCAT] = {
+		"MYCAT",
+		NULL,
+		"Whatever",
+		LOGL_NOTICE,
+		1,
+	};
+	linfo.cat = categories;
+	linfo.num_cat = ARRAY_SIZE(categories);
 
-	Log(LOG_EMERG).get() << " testing the logger.";
-	Log(LOG_ALERT).get() << " testing the logger.";
-	Log(LOG_CRIT).get() << " testing the logger.";
-	Log(LOG_ERR).get() << " testing the logger.";
-	Log(LOG_WARNING).get() << " testing the logger.";
-	Log(LOG_NOTICE).get() << " testing the logger.";
-	Log(LOG_INFO).get() << " testing the logger.";
-        Log(LOG_DEBUG).get() << " testing the logger.";
-    std::cout << "----------- generating 20 alarms ----------" << std::endl;
-    for (int i = 0 ; i < 20 ; ++i) {
-        Log(LOG_ALERT).get() << i;
-    }
+	osmo_init_logging(&linfo);
+
+	log_set_use_color(osmo_stderr_target, 0);
+	log_set_print_filename(osmo_stderr_target, 0);
+	log_set_print_level(osmo_stderr_target, 1);
+
+	Log(MYCAT, LOGL_FATAL).get() << "testing the logger.";
+	Log(MYCAT, LOGL_ERROR).get() << "testing the logger.";
+	Log(MYCAT, LOGL_NOTICE).get() << "testing the logger.";
+	Log(MYCAT, LOGL_INFO).get() << "testing the logger.";
+	Log(MYCAT, LOGL_DEBUG).get() << "testing the logger.";
 }
diff --git a/tests/CommonLibs/LogTest.err b/tests/CommonLibs/LogTest.err
index 718ff40..153e850 100644
--- a/tests/CommonLibs/LogTest.err
+++ b/tests/CommonLibs/LogTest.err
@@ -1,24 +1,3 @@
-EMERG  testing the logger.
-ALERT  testing the logger.
-CRIT  testing the logger.
-ERR  testing the logger.
-ALERT 0
-ALERT 1
-ALERT 2
-ALERT 3
-ALERT 4
-ALERT 5
-ALERT 6
-ALERT 7
-ALERT 8
-ALERT 9
-ALERT 10
-ALERT 11
-ALERT 12
-ALERT 13
-ALERT 14
-ALERT 15
-ALERT 16
-ALERT 17
-ALERT 18
-ALERT 19
+FATAL testing the logger.
+ERROR testing the logger.
+NOTICE testing the logger.
diff --git a/tests/CommonLibs/LogTest.ok b/tests/CommonLibs/LogTest.ok
index ac60314..e69de29 100644
--- a/tests/CommonLibs/LogTest.ok
+++ b/tests/CommonLibs/LogTest.ok
@@ -1,29 +0,0 @@
-EMERG  testing the logger.
-ALERT  testing the logger.
-CRIT  testing the logger.
-ERR  testing the logger.
-WARNING  testing the logger.
-NOTICE  testing the logger.
-INFO  testing the logger.
-DEBUG  testing the logger.
------------ generating 20 alarms ----------
-ALERT 0
-ALERT 1
-ALERT 2
-ALERT 3
-ALERT 4
-ALERT 5
-ALERT 6
-ALERT 7
-ALERT 8
-ALERT 9
-ALERT 10
-ALERT 11
-ALERT 12
-ALERT 13
-ALERT 14
-ALERT 15
-ALERT 16
-ALERT 17
-ALERT 18
-ALERT 19
diff --git a/tests/CommonLibs/Makefile.am b/tests/CommonLibs/Makefile.am
index 6bd1852..721c9a2 100644
--- a/tests/CommonLibs/Makefile.am
+++ b/tests/CommonLibs/Makefile.am
@@ -1,6 +1,7 @@
 include $(top_srcdir)/Makefile.common
 
-AM_CPPFLAGS = -Wall -I$(top_srcdir)/CommonLibs $(STD_DEFINES_AND_INCLUDES) -g
+AM_CPPFLAGS = -Wall -I$(top_srcdir)/CommonLibs $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOVTY_CFLAGS) -g
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOCTRL_LIBS) $(LIBOSMOVTY_LIBS)
 
 EXTRA_DIST = BitVectorTest.ok \
              PRBSTest.ok \