From 020bc26fec456cd471efdcd92a9c86bdc1b42fa6 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 31 May 2017 12:57:58 -0400 Subject: [PATCH] plugins/ctf/lttng-live: use standard logging files and macros MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- plugins/ctf/lttng-live/Makefile.am | 3 +- plugins/ctf/lttng-live/data-stream.c | 5 ++-- plugins/ctf/lttng-live/logging.c | 26 ++++++++++++++++ plugins/ctf/lttng-live/logging.h | 31 ++++++++++++++++++++ plugins/ctf/lttng-live/lttng-live-internal.h | 6 ---- plugins/ctf/lttng-live/lttng-live.c | 15 ++-------- plugins/ctf/lttng-live/metadata.c | 5 ++-- plugins/ctf/lttng-live/viewer-connection.c | 5 ++-- 8 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 plugins/ctf/lttng-live/logging.c create mode 100644 plugins/ctf/lttng-live/logging.h diff --git a/plugins/ctf/lttng-live/Makefile.am b/plugins/ctf/lttng-live/Makefile.am index dcd310ee..d65662e2 100644 --- a/plugins/ctf/lttng-live/Makefile.am +++ b/plugins/ctf/lttng-live/Makefile.am @@ -4,6 +4,7 @@ libbabeltrace_plugin_ctf_lttng_live_la_SOURCES = lttng-live.c \ data-stream.c lttng-live-internal.h \ data-stream.h metadata.c metadata.h \ viewer-connection.c viewer-connection.h \ - lttng-viewer-abi.h + lttng-viewer-abi.h \ + logging.c logging.h noinst_LTLIBRARIES = libbabeltrace-plugin-ctf-lttng-live.la diff --git a/plugins/ctf/lttng-live/data-stream.c b/plugins/ctf/lttng-live/data-stream.c index c3449234..5669b614 100644 --- a/plugins/ctf/lttng-live/data-stream.c +++ b/plugins/ctf/lttng-live/data-stream.c @@ -22,6 +22,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-SRC-DS" +#include "logging.h" + #include #include #include @@ -33,8 +36,6 @@ #include "../common/notif-iter/notif-iter.h" #include -#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-DS" - #include "data-stream.h" static diff --git a/plugins/ctf/lttng-live/logging.c b/plugins/ctf/lttng-live/logging.c new file mode 100644 index 00000000..e6f3c0c9 --- /dev/null +++ b/plugins/ctf/lttng-live/logging.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Philippe Proulx + * + * 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 lttng_live_log_level +#include + +BT_LOG_INIT_LOG_LEVEL(lttng_live_log_level, "BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_SRC_LOG_LEVEL"); diff --git a/plugins/ctf/lttng-live/logging.h b/plugins/ctf/lttng-live/logging.h new file mode 100644 index 00000000..e3f1632d --- /dev/null +++ b/plugins/ctf/lttng-live/logging.h @@ -0,0 +1,31 @@ +#ifndef LTTNG_LIVE_LOGGING_H +#define LTTNG_LIVE_LOGGING_H + +/* + * Copyright (c) 2017 Philippe Proulx + * + * 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 lttng_live_log_level +#include + +BT_LOG_LEVEL_EXTERN_SYMBOL(lttng_live_log_level); + +#endif /* LTTNG_LIVE_LOGGING_H */ diff --git a/plugins/ctf/lttng-live/lttng-live-internal.h b/plugins/ctf/lttng-live/lttng-live-internal.h index fa540927..115ac76b 100644 --- a/plugins/ctf/lttng-live/lttng-live-internal.h +++ b/plugins/ctf/lttng-live/lttng-live-internal.h @@ -28,15 +28,9 @@ * SOFTWARE. */ -extern int bt_lttng_live_log_level; - #include #include - -#define BT_LOG_OUTPUT_LEVEL bt_lttng_live_log_level -#include - #include #include #include diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index a84c9cc4..33cd94a0 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -27,6 +27,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-SRC" +#include "logging.h" + #include #include #include @@ -48,9 +51,6 @@ #include #include -#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE" -#define BT_LOGLEVEL_NAME "BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_LOG_LEVEL" - #include "data-stream.h" #include "metadata.h" #include "lttng-live-internal.h" @@ -83,9 +83,6 @@ static const char *print_state(struct lttng_live_stream_iterator *s) print_state(stream), stream->last_returned_inactivity_timestamp, \ stream->current_inactivity_timestamp) -BT_HIDDEN -int bt_lttng_live_log_level = BT_LOG_NONE; - BT_HIDDEN int lttng_live_add_port(struct lttng_live_component *lttng_live, struct lttng_live_stream_iterator *stream_iter) @@ -1117,9 +1114,3 @@ end: bt_put(self_port); return status; } - -static -void __attribute__((constructor)) bt_lttng_live_logging_ctor(void) -{ - bt_lttng_live_log_level = bt_log_get_level_from_env(BT_LOGLEVEL_NAME); -} diff --git a/plugins/ctf/lttng-live/metadata.c b/plugins/ctf/lttng-live/metadata.c index 7c8ce4dd..b71a42a5 100644 --- a/plugins/ctf/lttng-live/metadata.c +++ b/plugins/ctf/lttng-live/metadata.c @@ -23,6 +23,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-SRC-METADATA" +#include "logging.h" + #include #include #include @@ -32,8 +35,6 @@ #include #include -#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-METADATA" - #include "metadata.h" #include "../common/metadata/decoder.h" diff --git a/plugins/ctf/lttng-live/viewer-connection.c b/plugins/ctf/lttng-live/viewer-connection.c index 9b48421e..9f61f160 100644 --- a/plugins/ctf/lttng-live/viewer-connection.c +++ b/plugins/ctf/lttng-live/viewer-connection.c @@ -20,6 +20,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-SRC-VIEWER" +#include "logging.h" + #include #include #include @@ -39,8 +42,6 @@ #include #include -#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-VIEWER" - #include "lttng-live-internal.h" #include "viewer-connection.h" #include "lttng-viewer-abi.h" -- 2.34.1