python-plugin-provider: use standard logging files and macros
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 31 May 2017 17:01:36 +0000 (13:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 20:58:13 +0000 (16:58 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
python-plugin-provider/Makefile.am
python-plugin-provider/logging.c [new file with mode: 0644]
python-plugin-provider/logging.h [new file with mode: 0644]
python-plugin-provider/python-plugin-provider.c

index 00884e1e606ab1fac2740a41409cd341aaf26aad..145c46f347950a9cfcfdf3b5ff0dde82945f9b0f 100644 (file)
@@ -2,7 +2,8 @@ AM_CFLAGS = $(PYTHON_INCLUDE) $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
 
 lib_LTLIBRARIES = libbabeltrace-python-plugin-provider.la
 
-libbabeltrace_python_plugin_provider_la_SOURCES = python-plugin-provider.c
+libbabeltrace_python_plugin_provider_la_SOURCES = \
+       python-plugin-provider.c logging.c logging.h
 libbabeltrace_python_plugin_provider_la_LDFLAGS = \
        -version-info $(BABELTRACE_LIBRARY_VERSION) $(PYTHON_LIBS)
 
diff --git a/python-plugin-provider/logging.c b/python-plugin-provider/logging.c
new file mode 100644 (file)
index 0000000..c6ba438
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.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.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_INIT_LOG_LEVEL(python_plugin_provider_log_level,
+       "BABELTRACE_PYTHON_PLUGIN_PROVIDER_LOG_LEVEL");
diff --git a/python-plugin-provider/logging.h b/python-plugin-provider/logging.h
new file mode 100644 (file)
index 0000000..d5ab7ef
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef PYTHON_PLUGIN_PROVIDER_LOGGING_H
+#define PYTHON_PLUGIN_PROVIDER_LOGGING_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.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.
+ */
+
+#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
+#include <babeltrace/logging-internal.h>
+
+BT_LOG_LEVEL_EXTERN_SYMBOL(python_plugin_provider_log_level);
+
+#endif /* PYTHON_PLUGIN_PROVIDER_LOGGING_H */
index c276aadff3bd31989e19bc0873faba6624a051a4..26ada1ba85608e045d3bd38390aada4886dd3ad9 100644 (file)
  * SOFTWARE.
  */
 
-#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
 #define BT_LOG_TAG "PLUGIN-PY"
-#include <babeltrace/logging-internal.h>
-
-/*
- * Must be before the rest because some of the headers below could
- * contain logging statements which need this symbol when expanded.
- */
-static int python_plugin_provider_log_level = BT_LOG_NONE;
+#include "logging.h"
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler-internal.h>
@@ -65,13 +58,6 @@ enum python_state {
 
 static PyObject *py_try_load_plugin_module_func = NULL;
 
-static
-void __attribute__((constructor)) logging_ctor(void)
-{
-       python_plugin_provider_log_level =
-               bt_log_get_level_from_env("BABELTRACE_PYTHON_PLUGIN_PROVIDER_LOG_LEVEL");
-}
-
 static
 void print_python_traceback_warn(void)
 {
This page took 0.028226 seconds and 4 git commands to generate.