From 888d5a32617cf2567e01e5ee9336243017fad959 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 31 May 2017 12:52:27 -0400 Subject: [PATCH] plugins/ctf/common/btr: 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/common/btr/Makefile.am | 4 +++- plugins/ctf/common/btr/btr.c | 12 +----------- plugins/ctf/common/btr/logging.c | 26 +++++++++++++++++++++++++ plugins/ctf/common/btr/logging.h | 31 ++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 plugins/ctf/common/btr/logging.c create mode 100644 plugins/ctf/common/btr/logging.h diff --git a/plugins/ctf/common/btr/Makefile.am b/plugins/ctf/common/btr/Makefile.am index 4602514f..6d590d0c 100644 --- a/plugins/ctf/common/btr/Makefile.am +++ b/plugins/ctf/common/btr/Makefile.am @@ -3,4 +3,6 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include noinst_LTLIBRARIES = libctf-btr.la libctf_btr_la_SOURCES = \ btr.c \ - btr.h + btr.h \ + logging.c \ + logging.h diff --git a/plugins/ctf/common/btr/btr.c b/plugins/ctf/common/btr/btr.c index e4776cf6..58c3a286 100644 --- a/plugins/ctf/common/btr/btr.c +++ b/plugins/ctf/common/btr/btr.c @@ -23,11 +23,8 @@ * SOFTWARE. */ -#define BT_LOG_OUTPUT_LEVEL btr_log_level #define BT_LOG_TAG "PLUGIN-CTF-BTR" -#include - -static int btr_log_level = BT_LOG_NONE; +#include "logging.h" #include #include @@ -165,13 +162,6 @@ struct bt_ctf_btr { } user; }; -static -void __attribute__((constructor)) logging_ctor(void) -{ - btr_log_level = - bt_log_get_level_from_env("BABELTRACE_PLUGIN_CTF_BTR_LOG_LEVEL"); -} - static inline const char *btr_state_string(enum btr_state state) { diff --git a/plugins/ctf/common/btr/logging.c b/plugins/ctf/common/btr/logging.c new file mode 100644 index 00000000..ded29336 --- /dev/null +++ b/plugins/ctf/common/btr/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 btr_log_level +#include + +BT_LOG_INIT_LOG_LEVEL(btr_log_level, "BABELTRACE_PLUGIN_CTF_BTR_LOG_LEVEL"); diff --git a/plugins/ctf/common/btr/logging.h b/plugins/ctf/common/btr/logging.h new file mode 100644 index 00000000..d32de29b --- /dev/null +++ b/plugins/ctf/common/btr/logging.h @@ -0,0 +1,31 @@ +#ifndef CTF_BTR_LOGGING_H +#define CTF_BTR_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 btr_log_level +#include + +BT_LOG_LEVEL_EXTERN_SYMBOL(btr_log_level); + +#endif /* CTF_BTR_LOGGING_H */ -- 2.34.1